Property ‘spring.profiles.active’ imported from location ‘class path resource [application-test.yml]’ is invalid in a profile specific resource

Error: The property spring.profiles.active imported from location class path resource [application-test.yml] is invalid in a profile-specific resource.

Explanation:

In Spring Boot, the spring.profiles.active property is used to activate specific profiles in your application. Profiles are used to configure different sets of properties based on the environment or deployment scenario.

From the provided error message, it seems that there is an issue with the spring.profiles.active property defined in the application-test.yml file. The error is indicating that the imported property is invalid within a profile-specific resource.

This error can occur due to several reasons:

  1. The property value is not set correctly.
  2. The property key is misspelled or does not exist.
  3. The property is located in the wrong profile-specific resource.

To fix this error, you should check the following:

  1. Verify the value of the spring.profiles.active property in the application-test.yml file. Make sure it is set correctly according to your desired active profiles.
  2. Double-check the spelling and existence of the property key. Ensure that it matches the key used in your application’s code or other configuration files.
  3. Ensure that the spring.profiles.active property is defined in the correct profile-specific resource. If you have multiple property files for different profiles, make sure the property is set in the appropriate file for the active profile.

Example:

Suppose we have an application with two profiles: development and production. The application-test.yml file is used for the development profile, and we want to activate it using the spring.profiles.active property.

In the application-test.yml file, we would set the following:

    # application-test.yml
spring.profiles.active: development
    
  

This configuration will activate the development profile when running the application with the application-test.yml file as the configuration source.

Leave a comment