Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring.profiles.active is not working in springboot application

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.

like image 384
Sunil Rk Avatar asked Sep 17 '25 14:09

Sunil Rk


1 Answers

you can also try to run the application and pass them as command line args

java -jar -Dspring.profiles.active={your_profile_name} application.jar

or 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 : https://www.baeldung.com/spring-profiles

like image 115
Opri Avatar answered Sep 20 '25 05:09

Opri