The springboot project (jar package) specifies the configuration file to start

IDE development tools start

Configuration in JetBrains IDEA development tools

1. Startup class startup method

idea active profiles method

2. Main method startup method

--spring.profiles.active=devConfigure this command in program arguments in IDEA
program argument method
idea program arguments

3. JVM startup method

-Dspring.profiles.active=devConfigure this command in VM options in IDEA
idea vm options
idea vm options

jar package start

1. Specify the configuration environment

nohup java -jar -Dfile.encoding=utf-8 -Dspring.profiles.active=dev example.jar >/dev/null 2>&1 &

This startup method will load the application-dev.yml or application-dev.properties file in the resource directory of the Jar package. At the same time, it should be noted that the startup method of IDEA is the same.

2. Specify the configuration file

yml file

nohup java -jar -Dfile.encoding=utf-8 -Dspring.config.location=classpath:/application-dev.yml example.jar >/dev/null 2>&1 &

properties file

nohup java -jar -Dfile.encoding=utf-8 -Dspring.config.location=classpath:/application-dev.properties example.jar >/dev/null 2>&1 &

If the configuration file is outside the Jar package, you can directly use the relative or absolute path of the configuration file without classpath after -Dspring.config.location=:
for example -Dspring.config.location=app-dev.yml
-Dspring.config.location=/usr/local/soft/config/app-dev.yml

Guess you like

Origin blog.csdn.net/m0_54255522/article/details/129858734