A Spring Bot application can be deployed in several ways:
In its bare essence, a Spring Boot application is a plain Java application with a main method. As long as all the dependency are met, it can run.
This is the simplest deployment variant, as we do not have to set up anything at all. By using the Spring Boot Maven Parent, we already get a configured version of the Spring Boot Maven Plugin. So, whenever we run mvn package
or mvn install
, Spring Boot will build a single FatJar file with all the dependencies included. It’s in the target folder.
Start it with:
java -jar comment-store-1.0.0-SNAPSHOT.jar
It will start the application as during implementation with the difference now, that everything is included in this single file.
In short, we need to reconfigure the Spring Boot Maven Plugin like:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
It will now add a starting shell script at the beginning of the Jar file. The script is compatible with init.d.
More in Spring Boot: How To Get Started and Build a Microservice
The application is still built as a FatJar, but instead of running on your own server or virtual server, we put the build artifact to a cloud provider.
See instructions for: