If you make a Jar in the form of Fully Executable Jar, a script will be added to the beginning of the Jar and output. This script can be used as it is as a script for starting the service.
To create it, make the contents of the
<build> tag in pom.xml as follows.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <executable>true</executable> </configuration> </plugin> </plugins> </build>
<executable> true </ executable> is the key
Create a file with the same name as the Jar file to be executed but with the extension changed to
The contents are the definition of environment variables, options to be passed to java, and runtime arguments to be passed to jar.
For systemd such as CentOS7, it is OK if you create a service file in
/ etc / systemd / system /
[Unit] Description = <Service description> [Service] ExecStart = /home/application/hoge.jar Restart = always Type = simple User = application Group = application SuccessExitStatus = 143 [Install] WantedBy = multi-user.target
$ sudo systemctl start hoge
Can do something