Spring Boot app: Not picking up application.properties?
I used Spring Boot 2.0.0 and I faced same problem. With version 1.4.3 it worked perfectly.
Reason is that if you define this argument:
-Dspring.config.location=file:/app/application-prod.yml
Spring Boot now is not adding default locations to search.
Solution:
-Dspring.config.location=file:/app/application-prod.yml,classpath:application.yml
See:
- /org/springframework/boot/context/config/ConfigFileApplicationListener.java
- https://docs.spring.io/spring-boot/docs/2.0.1.BUILD-SNAPSHOT/reference/htmlsingle/#appendix
This was obscure - and the other answers were very helpful in getting me pointed in the right direction.
After trying the suggested solutions, I poked around deeper and found this in Project Properties --> Java Build Path --> Source(tab) --> Source folders on build path: [Exclusion section]
**/application.properties
Removing the exclusion fixed the issue and the values were picked up from the application.properties file during startup.
It may be worth noting that running this from the command line (in the directory with the .project file) bypassed the exclusion problem and worked fine.
mvn spring-boot:run
For me it was due to packaging as pom
I had something in my pom.xml as below
<packaging>pom</packaging>
So if you have similar thing,
Remove it for spring-boot App.
Delete target folder or mvn clean.
- then mvn install.
- Watch your property under target/classes/application.properties file.