spring-boot添加到linux服务

在/usr/lib/systemd/system/下创建service文件


   
   
  1. [Unit]
  2. Description=myfee
  3. [Service]
  4. WorkingDirectory=/usr/share/web-app
  5. ExecStart=/usr/share/jdk1.8.0_151/bin/java -jar /usr/share/web-app/myfee-api-1.0.0.jar --spring.profiles.active=wxdev
  6. [Install]
  7. WantedBy=multi-user.target

需要打包的工程pom.xml文件中的spring-boot-maven-plugin添加如下配置

<executable>true</executable>
   
   

整个plugin举例如下

   
   
  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.springframework.boot </groupId>
  5. <artifactId>spring-boot-maven-plugin </artifactId>
  6. <configuration>
  7. <source>1.8 </source>
  8. <target>1.8 </target>
  9. <fork>true </fork>
  10. <executable>true </executable>
  11. <excludeDevtools>false </excludeDevtools>
  12. </configuration>
  13. <executions>
  14. <execution>
  15. <goals>
  16. <goal>repackage </goal>
  17. </goals>
  18. </execution>
  19. </executions>
  20. </plugin>
  21. </plugins>
  22. </build>
打包后给jar包授权 chmod a+x xxx.jar

之后就可以使用systemctl service文件名 start/status/stop命令来启动,查看状态,停止应用了



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值