Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is diff between spring.profiles.active vs spring.config.activate.on-profile?

What is exact difference between spring.profiles.active and spring.config.activate.on-profile?

"WARN","msg":"Property 'spring.profiles' imported from location 'class path resource [application.yaml]' is invalid and should be replaced with 'spring.config.activate.on-profile' [origin: class path resource [application.yaml]

like image 697
Prashant kamble Avatar asked Dec 27 '25 20:12

Prashant kamble


1 Answers

spring.profiles.active can be used to specify which profiles are always active.
An example from the documentation:

spring:
  profiles:
    active: "production"

spring.config.activate.on-profile (known as spring.profiles before Spring Boot 2.4) can be used to mark a configuration file segment profile-specific.
An example from the documentation:

server:
  port: 9000
---
spring:
  config:
    activate:
      on-profile: "development"
server:
  port: 9001
---
spring:
  config:
    activate:
      on-profile: "production"
server:
  port: 0

In the preceding example, the default port is 9000. However, if the Spring profile called ‘development’ is active, then the port is 9001. If ‘production’ is active, then the port is 0.

Another change in Spring Boot 2.4 was that the spring.profiles.active property is no longer allowed in combination with spring.config.activate.on-profile. (See this blog post for details.)

like image 143
snorbi Avatar answered Dec 30 '25 23:12

snorbi