This project enables a Spring Boot application to be managed as a service on Windows.
There is no need for Spring Boot Daemon on Unix thanks to the native Spring Boot support from 1.3 onwards.
The windows
distribution uses winsw
.
Warning
|
You need to install the .NET framework on the target machine first.
|
To install the application as a service, extract the distribution zip somewhere and open a shell with administrative rights in that directory.
C:\dir> install.bat
Once the service has been installed, you can start it the usual way, that is:
C:\dir> startup.bat
C:\dir> shutdown.bat
C:\dir> run.bat
C:\dir> status.bat
Note: A result of NonExistent
means the service is not installed.
C:\dir> shutdown.bat C:\dir> uninstall.bat
Or, How to convert your application into a Windows Service.
To enable running your own Spring Boot applications as a Windows Service:
-
add
net.kemitix:spring-boot-daemon-integration
as a dependency -
copy, unaltered, the
assembly
anddist
directories fromspring-boot-daemon-sample/src/main
into your own application sources -
add the
project/build/plugins
section fromspring-boot-daemon-sample/pom.xml
to your ownpom.xml
, including thespring-boot-maven-plugin
(needs layout=ZIP), which should be first among these plugins -
add the following properties and repositories to your
pom.xml
, updating the values to suit:
<properties>
<spring-boot.version>1.3.5.RELEASE</spring-boot.version>
<start-class>net.nicoll.SampleApplication</start-class> <!--(1)-->
<winsw.version>1.18</winsw.version>
<maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
<maven-resources-plugin.verion>2.7</maven-resources-plugin.verion>
<maven-assembly-plugin.version>2.6</maven-assembly-plugin.version>
<dist.dir>${project.build.directory}/dist</dist.dir>
<dist.service.name>${project.artifactId}</dist.service.name>
<dist.service.display.name>Sample Spring Boot App</dist.service.display.name> <!--(2)-->
<dist.service.description>
Demonstrate how to integrate a Spring Boot app as a Windows Service <!--(3)-->
</dist.service.description>
<dist.jar>lib\${project.artifactId}-${project.version}.jar</dist.jar>
<dist.start.class>${start-class}</dist.start.class>
<dist.jmx.port>50201</dist.jmx.port> <!--(4)-->
</properties>
<repositories>
<repository><!-- repo for downloading winsw.exe from -->
<id>jenkins</id>
<name>Jenkins Repository</name>
<url>http://repo.jenkins-ci.org/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
-
Your Spring Boot application class
-
The name that shows in the Windows Services Control Panel
-
The longer description that shows in the Windows Services Control Panel
-
The JMX Port on the machine that will be assigned to the server, must not conflict with another usage and is required to be able to shutdown the service