1. Spring boot under ide
-
The springboot project has the following configuration files
-
There is a main configuration file
application.yml
, specify the actual configuration file in the main configuration file# 公共配置 server: port: 8080 servlet: context-path: / # 设置指定配置文件生效, 指定application-dev.yml的配置文件生效 spring: profiles: active: dev
-
@SpringBootApplication
Start directly under the main method of the annotation
2. Under the configuration of (1), use the command to start
- Need to ensure that the project has been packaged into a jar package:
springboot-demo.jar
- Use
java -jar
startup to start based on the configuration file under (1)java -jar springboot-demo.jar
3. Under the configuration of (1), start the project by specifying other configuration files in the project
- Need to ensure that the project has been packaged into a jar package:
springboot-demo.jar
application-pro.yml
Start the project by specifying other configuration files in the project- Sometimes the start command will fail
java -jar springboot-demo.jar --spring.profiles.active=test
- Another start command (when the previous start command is invalid, use the following, or just use this)
java -jar -Dspring.profiles.active=test springboot-demo.jar
- Sometimes the start command will fail
4. Start the springboot project based on (3) on the Linux server
- Direct start
java -jar -Dspring.profiles.active=test springboot-demo.jar
- Does not display the start of log printing
Notenohup java -jar -Dspring.profiles.active=test springboot-demo.jar &
nohup
Command: Run the command without hanging up.
nohup
It will result in the execution log output to the current folder the followingnohup.out
file
Reference source
Springboot specifies the configuration file to
start the springboot project in the background under linux