Spring Boot CentOS 服务部署

服务默认存放目录

1
cd /etc/systemd/system/multi-user.target.wants
  • 1.创建应用服务配置,示例命名为 /root/my-spring-boot/my-spring-boot.service

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    [Unit]
    Description=服务名称,随便写
    After=syslog.target
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/java -jar -Dspring.profiles.active=test /root/my-spring-boot/app.jar
    
    [Install]
    WantedBy=multi-user.target
    
  • 2.创建软连接

    1
    
    ln -s /root/my-spring-boot/my-spring-boot.service /etc/systemd/system/multi-user.target.wants/my-spring-boot.service
    
  • 3.更新systemctl

    1
    
    systemctl daemon-reload
    

引用参考