Running Spring Boot applications as a Service is pretty simple and this tutorial will show how to do it in just 5 minutes.

In order to install your Spring Boot application as a service, you need to add an additional item into the plugin you are using to build Spring Boot. For example, if you are using Maven to build your project, then add to the configuration section the executable stanza as in this example:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <!-- ...all the previous code -->
   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
               <executable>true</executable>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

Much the same way, you can make executable your application if you are using the build.gradle Gradle configuration:

apply plugin: 'spring-boot'
springBoot {
executable = true
}

Now, when you package your application with the following:

$ ./mvnw clean package -DskipTests=true

You can execute the JAR directly:

$ target/demoapp.war

So, if you are running a Linux environment you can just bind it to the /etc/init.d

$ ln -s /opt/demoapp.war /etc/init.d/demoapp

Then you can start your application with the following:

$ service demoapp start

That's all! Enjoy running Spring Boot apps as a Service!