I have created Profiles in Java class like this,
@Profile(value = "cache")
public class MapCache {
....
}These profiles are not getting activated when spring.profiles.active used, but if i use spring.profiles.include profiles are working fine.
I would like activate profiles through properties which are added in application.properties
Note: application is running in independent jetty instance.
Any tip would be great on this.
2 Answers
To activate a profile via annotations you need @ActiveProfile("profileName"). The @Profile annotation is used to label an object as being a member of the profile.
you can also try to run the application and pass them as command line args
java -jar -Dspring.profiles.active={your_profile_name} application.jaror if you run the app via maven:
mvn spring-boot:run -Dspring-boot.run.profiles={your_profile_name}Here is an nice example I found on the internet with all the ways you can set the spring profile, it should help :