Property ‘spring.profiles’ imported from location ‘class path resource [application.yml]’ is invalid and should be replaced with ‘spring.config.activate.on-profile’

The error message you are seeing is related to the configuration property ‘spring.profiles’ in the ‘application.yml’ file. This property is considered invalid and should be replaced with ‘spring.config.activate.on-profile’.

The ‘spring.profiles’ property is used to activate specific profiles in Spring Boot applications. However, in newer versions of Spring Boot, the recommended property to achieve the same functionality is ‘spring.config.activate.on-profile’.

Here’s an example to illustrate how to replace the ‘spring.profiles’ property with ‘spring.config.activate.on-profile’ in the ‘application.yml’ file:

    # application.yml

    spring:
      config:
        activate:
          on-profile: development
  

In the example above, the ‘spring.config.activate.on-profile’ property is set to ‘development’. This means that the application will only activate the ‘development’ profile when running.

You can replace ‘development’ with any other profile name that you want to activate.

Make sure to update the ‘application.yml’ file accordingly and restart your application for the changes to take effect.

Leave a comment