For me the easiest way to do it, was to place a context file inside Tomcat's config folder. For example if your application is running under root path (eg. http://your_domain.com/
) you need to create a file [path_to_your_tomcat]/conf/Catalina/localhost/ROOT.xml
. If your application runs in a different path, for example http://your_domain.com/example_path
the file should be named like this [path_to_your_tomcat]/conf/Catalina/localhost/example_path.xml
. Inside this file you can specify a path to the external application.properties file that can be placed anywhere on your hard drive.
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Environment name="spring.config.location" value="file:/path/to/your/application/properties/file/" type="java.lang.String"/>
</Context>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…