springboot specifies the configuration file to start the project

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
    
  • @SpringBootApplicationStart 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 -jarstartup 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.ymlStart 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
      


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
    nohup  java -jar -Dspring.profiles.active=test springboot-demo.jar &
    
    Note
    nohup Command: Run the command without hanging up.
    nohupIt will result in the execution log output to the current folder the followingnohup.outfile



Reference source

Springboot specifies the configuration file to
start the springboot project in the background under linux

Guess you like

Origin www.cnblogs.com/vitoboy/p/12729663.html