I've been using Spring Boot
for a few weeks already, and I'm used to work with the application.properties
file. I'm able to use it for simple deployment and use with java jar
or mvn spring-boot:run
.
Now I'm trying to deploy my application to a Tomcat 8.0.15
application server. I've been reading of documentation, but I can't deploy the war
file because Tomcat can't find this famous application.properties
file. My point is, if I want to put this file out of the war
, where in my Tomcat installation should I put it for it to be automatically read?
If you don't want to change it later, just put it in the root of your classpath, e.g. if it's Maven project then inside
<project-folder>/src/main/java/
If you want to change it later without rebuilding WAR then in Tomcat properties file
catalina.properties
there is
shared.loader=
that makes properties files listed after equals sign accessible to deployed applications. Better use absolute paths.
BTW, I would opt to use annotation-based configuration nowadays, but then again, it doesn't have the comfort of changing without rebuilding WAR.
Spring loads the properties from
1) A /config subdir of the current directory.
2) The current directory
3) A classpath /config package
4) The classpath root
See the docs(23.2 Application property files): http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-external-config-application-property-files
This should work the same way for war(The classpath root one looks the best for me) .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With