Starting Spring boot applications from script

前端 未结 4 1048
醉梦人生
醉梦人生 2021-01-17 04:28

Using normal spring mvn commands, I can start a spring boot application from command line and terminate it with Control+c. I however have created a bunch of services which I

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-17 05:16

    I would follow the documentation to install Spring-Boot application as a Unix/Linux service.

    All you have to do is to add this dependency to your pom.xml:

    
        org.springframework.boot
        spring-boot-maven-plugin
        
            true
        
    
    

    After adding the plugin you should install and create a symlink to your application (exact part of documentation):

    Assuming that you have a Spring Boot application installed in /var/myapp, to install a Spring Boot application as an init.d service simply create a symlink:

    $ sudo ln -s /var/myapp/myapp.jar /etc/init.d/myapp

    Once installed, you can start and stop the service in the usual way. For example, on a Debian based system:

    $ service myapp start

    Then you are able to create a bash script to start, stop or restart your applications in a clean way.

提交回复
热议问题