How to determine programmatically the current active profile using Spring boot [duplicate]

Is there a way programmatically to get the current active profile within my bean?


It doesn't matter is your app Boot or just raw Spring. There is just enough to inject org.springframework.core.env.Environment to your bean.

@Autowired
private Environment environment;
....

this.environment.getActiveProfiles();