IDE development tools start
Configuration in JetBrains IDEA development tools
1. Startup class startup method
2. Main method startup method
--spring.profiles.active=dev
Configure this command in program arguments in IDEA
3. JVM startup method
-Dspring.profiles.active=dev
Configure this command in VM options in IDEA
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