How do I check if my spring application is in the production environment?

3

When in production, when I fall into an exception, send an email to the support but only in production, in development I do not want it to perform this task.

    
asked by anonymous 19.08.2015 / 20:55

1 answer

4

The solution was to inject a spring boot class called Environment.

@Autowired
private Environment environment;

environment.getActiveProfiles()[0].equals("production"));

Application.properties file

#ENVIRONMENT
spring.profiles.active=develop
    
14.09.2015 / 15:38