1

I just upgraded the Spring Boot Starter Parent dependency 2.7.5 --> 3.0.2.

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.2</version>
    <relativePath />
</parent>

Note that the application.yml already has the following Legacy Processing mode setting, which should prevent the error below:

spring.config.use-legacy-processing: true

There are different profiles defined in application.yml as follows:

spring:
  profiles.active: dev
  profiles: dev
  rails:
    url: ...
    userIdentifier: ...
    service: FILESERVICE
    methodInBody: POST
    uri: /api/external-interfaces/file-locations
   
---
spring:
  profiles: stage
  rails:
    url: ...
    userIdentifier: ...
    service: FILESERVICE
    methodInBody: POST
    uri: /api/external-interfaces/file-locations
  jackson:
    serialization:
      indent-output: true
---
spring:
  profiles: prod
  rails:
    url: ...
    userIdentifier: ...
    service: FILESERVICE
    methodInBody: POST
    uri: /api/external-interfaces/file-locations

Error on mvn spring-boot:run:

org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.profiles' imported from location 'class path resource [application.yml]' is invalid and should be replaced with 'spring.config.activate.on-profile' [origin: class path resource [application.yml] - 41:13]

Do I just need to replace all 3 occurrences of profiles: with spring.config.activate.on-profile: ?

Zak
  • 6,976
  • 2
  • 26
  • 48
gene b.
  • 10,512
  • 21
  • 115
  • 227

1 Answers1

2

I had to re-write it as follows per this thread: https://stackoverflow.com/a/73791460/1005607

  • spring.profiles has to be replaced with spring.config.activate.on-profile

  • if spring.profiles.active exists (this is still allowed), it cannot coexist with any spring.config.activate.on-profile

    spring:
       profiles.active: dev
       rails:
         url: ..
         userIdentifier: ..
         service: FILESERVICE
         methodInBody: POST
         uri: /api/external-interfaces/file-locations
    
     ---
     spring:
       config:
          activate:
              on-profile: stage
       rails:
         url: ..
         userIdentifier: ..
         service: FILESERVICE
         methodInBody: POST
         uri: /api/external-interfaces/file-locations
       jackson:
         serialization:
           indent-output: true
     ---
     spring:
       config:
          activate:
              on-profile: prod
       rails:
         url: ..
         service: FILESERVICE
         methodInBody: POST
         uri: /api/external-interfaces/file-locations
    
gene b.
  • 10,512
  • 21
  • 115
  • 227