java - springboot war放入tomcat启动怎么指定使用外部application.properties
ringa_lee
ringa_lee 2017-04-18 10:53:02
0
4
806

springboot war放入tomcat启动怎么指定使用外部application.properties

ringa_lee
ringa_lee

ringa_lee

reply all(4)
巴扎黑

Resource supports file:d:/myspring/banner.txt,
then @PropertySource("file:///user/myspring/application.properties") should also be possible, you can try it, I have not tried it.

Peter_Zhu

You can add environment variables to the catalina.sh file in tomcat's bin directory
For example: the tomcat directory is named demo.

First, modify the catalina.sh file
around line 230

f [ -z "$JSSE_OPTS" ] ; then
  JSSE_OPTS="-Djdk.tls.ephemeralDHKeySize=2048"
fi
JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS"
#添加配置文件路径

#=======================WEB APP===============================
JAVA_OPTS="$JAVA_OPTS -DWEB APP_PROPERTY_FILE=/home/tomcat/demo/conf/WebProperties.properties"
#=======================WEB APP================================

Then, upload the WebProperties.properties file to the conf directory under tamcat named demo

Finally, when importing the configuration file into the project, use ${WEB APP_PROPERTY_FILE} to get the configuration file path.

When developing locally, when importing the configuration file, use filePath="file:C/Test/WebProperties.properties" to import it. Of course, environment variables can also be configured.

The above is the solution in our project. It may vary due to different environments, please refer to it yourself

Ty80

Environment in tomcat can specify spring.config.location = application property files

黄舟

It’s really not easy to make it into a war package, but hasn’t it been changed to online configuration before going online? Or define multiple configuration files and specify which one to use when starting with a command

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template