015. Profile - dkkahm/study-springfamework5 GitHub Wiki
Bean with Profile
- Bean without Profile will be loaded always
@Service
@Profile("es")
public class PrimarySpanishGreetingService implements GreetingService {
Set Active Profile ()
- https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-properties-and-configuration
- application.properties
- spring.profiles.active=es
- environment variable
- SPRING_PROFILES_ACTIVE
- command line
- java -jar application.jar --spring.profiles.active=prod --spring.config.location=c:\config
Bean with Default Profile
@Service
@Primary
@Profile({"de", "default"})
public class PrimaryGermanGreetingService implements GreetingService {