. Advertisement .
..3..
. Advertisement .
..4..
In 1991, James Gosling and his colleagues at Sun MicroSystems launched Java. Oak was the name given to Java when it was created for writing software for household products. So, Java is a great object-oriented programming language and used to create software, websites, games, and mobile applications.
Many users, including ourselves, may still run into many errors when running their code. You may face this problem, “ERROR org.springframework.boot.SpringApplication – Application run failed org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid in a profile specific resource“.
This is a common error made by all programmers. What caused it, and what can be done now to address it? We will work together to find the best solutions.
Why Does The Error “ERROR org.springframework.boot.SpringApplication – Application run failed org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid in a profile specific resource” Occur?
You are developing a Spring cloud application, and when you run it, you get the following error.
[Main] ERROR org.springframework.boot.SpringApplication – Application run failed
org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid in a profile specific resource [origin: class path resource [application-dev.yml] from skyshop-mail-1.0.jar – 42:17]
at org.springframework.boot.context.config.InvalidConfigDataPropertyException.lambda$throwOrWarn$1(InvalidConfigDataPropertyException.java:125)
This error can come from updating Spring cloud application to the latest Spring boot version 2.5.0., that can named the function of application.yml and application-dev.yml file.
The exiting Spring Boot Version is very strict with the naming conventions that is based on the environment. You cannot inject application properties during runtime. You will need to create application-.properties for each environments, which will be picked based on active profile.
The top simple methods to correct the problem
“ERROR org.springframework.boot.SpringApplication – Application run failed org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid in a profile specific resource”
And guess what? You can solve this problem with some simple methods.
Method 1: Change the spring.profiles.active
In this solution, change spring.profiles.active to dev in the application-dev.yml file.
With the aid of Spring Profiles, you may separate different aspects of your application’s settings and limit their accessibility to specific environments. To restrict when it is loaded, any @Component or @Configuration can be designated with @Profile:
@Configuration
@Profile("production")
public class ProductionConfiguration {
// ...
}
You can indicate which profiles are active using a spring.profiles.active Environment property, as is standard practice with Spring. Any of the common methods can be used to specify the property, such as adding it to your application. properties:
spring.profiles.active=dev,hsqldb
Alternatively specify using the switch —spring.profiles.active=dev,hsqldb on the command line.
Method 2: Rename the application-dev.yml to application-local.yml
Renaming application-dev.yml to application-local.yml and using the local profile is also a great way for you to resolve the error “ERROR org.springframework.boot.SpringApplication – Application run failed org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid in a profile specific resource” in Java.
Method 3: Rename application-dev.yml to application-dev123.yml
Another way to solve your problem is to rename application-dev.yml to application-dev123.yml.
Method 4: Mention the following in your application-dev.yml
To solve the error “ERROR org.springframework.boot.SpringApplication – Application run failed org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid in a profile specific resource”, let’s mention the following in your application-dev.yml:
spring:
application:
name: mail-service
profiles:
active: local
After doing that, your error completely disappear.
Conclusion
The solutions presented above are suggestions for those still perplexed by the message “ERROR org.springframework.boot.SpringApplication – Application run failed org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property ‘spring.profiles.active’ imported from location ‘class path resource [application-dev.yml]’ is invalid in a profile specific resource”
If you still need assistance or have a lot of questions, we have a large community where everyone is usually willing to help. Lastly, we want to thank everyone who has read this far and wishes you a pleasant day of interesting code solutions.
Read more
Leave a comment