

Table of Contents
1. Overview
In this article, We will learn about how to run spring boot as windows service or process. We will use winsw
service wrapper to run spring boot application as service in window OS. winsw
is service wrapper which is useful to run a process as daemons.
2. Steps to Configure spring boot as windows service or process
Using following steps we can run java jar or spring boot jar file as window process.
Step 1: Download Service Wapper
- Download
winsw
service wrapper from here. For example, we have downloadwinsw-2.1.2-bin.exe
Step 2: Rename Service Wapper
- Rename
winsw-2.1.2-bin.exe
tomy-spring-boot-service.exe
Step 3: Create Configuration XML file
- Create
my-spring-boot-service.xml
in the same location wheremy-spring-boot-service.exe
is available.
NOTE: Make sure that
.exe
and.xml
file name must be same, so our .exe file name ismy-spring-boot-service.exe
and.xml
ismy-spring-boot-service.xml
my-spring-boot-service.xml
- Here are some configuration related to services like service name, service id and description. here are more options about configuration XML file.
executable
indicate the location ofjava.exe
file which will be responsible to execute .jar file. Writejava.exe
‘s full path otherwise it service will throw an error like :
Error 1067: The process terminated unexpectedly.
arguments
where is our actual command to execute .jar
, Our jar name isdemo.jar
- We can also change user context in which service will be run, Here is a document to change user context
<service> <id>my-spring-boot-service</id> <name>my-spring-boot-service</name> <description>Java Developer Zone - Spring boot as windows service example</description> <executable>C:\Program Files\Java\jre1.8.0_51\bin\java</executable> <arguments>-jar "%BASE%\demo.jar"</arguments> <logmode>rotate</logmode> </service>
Step 4: Copy Jar File
- Copy jar file at same directory where
my-spring-boot-service.exe
andmy-spring-boot-service.xml
files are available.
It will look as below:

spring boot window service – directory
Step 5: Install Service
- Now open terminal, Go to the directory where our files are available and execute below command:
> my-spring-boot-service.exe install
2018-05-16 20:42:51,066 INFO - Installing the service with id 'my-spring-boot-service'
If service installs successfully, Let’s check in services inside windows:

spring boot window service – my-spring-boot-service
Step 6: Start & Stop Service
> my-spring-boot-service.exe start
2018-05-16 20:52:50,395 INFO - Starting the service with id 'my-spring-boot-service'
> my-spring-boot-service.exe stop
2018-05-16 20:54:29,264 INFO - Stopping the service with id 'my-spring-boot-service'
Step 7: Uninstall Service
> my-spring-boot-service.exe uninstall
2018-05-16 20:50:37,897 INFO - Uninstalling the service with id 'my-spring-boot-service' 2018-05-16 20:50:37,906 WARN - The service with id 'my-spring-boot-service' is running. It may be impossible to uninstall it
3. Concussion
In this article, We have learned steps install spring boot application as windows service using winsw windows service wrapper.
4. References