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.
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
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
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.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
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
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