56. Installing Spring Boot applications
In additional to running Spring Boot applications using java -jar
it is also possible to make fully executable applications for Unix systems. This makes it very easy to install and manage Spring Boot applications in common production environments.
To create a ‘fully executable’ jar with Maven use the following plugin configuration:
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <executable>true</executable> </configuration> </plugin>
With Gradle, the equivalent configuration would be:
apply plugin: 'spring-boot' springBoot { executable = true }
You can then run your application by typing ./my-application.jar
(where my-application
is the name of your artifact).
Note | |
---|---|
Fully executable jars work by embedding an extra script at the front of the file. Not all tools currently accept this format so you may not always be able to use this technique. |
Note | |
---|---|
The default script supports most Linux distributions and is tested on CentOS and Ubuntu. Other platforms, such as OS X and FreeBSD, will require the use of a custom embeddedLaunchScript . |
Note | |
---|---|
When a fully executable jar is run, it uses the jar’s directory as the working directory. |