

Spring Boot as a Windows Service in 5 minutes | Java Code Geeks - 2017
source link: https://www.javacodegeeks.com/2017/12/spring-boot-windows-service-5-minutes.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Home » Java » Enterprise Java » Spring Boot as a Windows Service in 5 minutes
About Martin Farrell

Spring Boot as a Windows Service in 5 minutes
Posted by: Martin Farrell in Enterprise Java December 15th, 2017 0 344 Views
I recently had to deploy a Spring Boot application as a windows service and am surprised how easy it was using winsw. I’d previously written about using procrun – Java Programs as Windows Services, but winsw is much easier
Getting Started
There is a Section 59 of the Spring Boot documentation is about Installing Spring Boot applications, and points you towards a github page. This example uses that project for inspiration.
Project
Im going to use the Spring IO “Serving Web Content” project as a starting point, so go to the web page and download the example from git or as a zip file.
We can then see our application running –
Wrapping as a Windows Service
- Download winsw from github – remember to choose the correct version depending on the version of .net you are running
- Create windowsservice directory and copy the exe to this location
- I renamed the gs-serving-web-content-0.1.0.jar to gs-serving-web-content.jar
- Rename winsw exe from WinSW.NET4.exe to gs-serving-web-content.exe
- Create a xml file named gs-serving-web-content.xml with the following content –
<? xml version = "1.0" encoding = "UTF-8" ?> < service > < id >gs-serving-web-content</ id > < name >gs-serving-web-content</ name > < description >gs-serving-web-content Windows Service</ description > < executable >java</ executable > < arguments >-jar "gs-serving-web-content.jar"</ arguments > < logmode >rotate</ logmode > </ service > |
- We can then install with gs-serving-web-content.exe install (you may need to run as administrator)
- We can then run this as a windows service –
Windows Service
- To uninstall we run – gs-serving-web-content.exe uninstall
Alternatives
I looked at procrun as an alternative wrapper for Spring Boot – but couldnt get it to work. It probably can – but needs more time.
Conclusion
Im really impressed with winsw for installing Spring boot applications as windows services. Its really simple, and you can pass external application.properties files in through the xml configuration
Published on Java Code Geeks with permission by Martin Farrell, partner at our JCG program. See the original article here: Spring Boot as a Windows Service in 5 minutes Opinions expressed by Java Code Geeks contributors are their own. |
Tagged with: Spring Boot
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!To get you started we give you our best selling eBooks for FREE!1. JPA Mini Book2. JVM Troubleshooting Guide3. JUnit Tutorial for Unit Testing4. Java Annotations Tutorial5. Java Interview Questions6. Spring Interview Questions7. Android UI Designand many more ....Email address: Receive Java & Developer job alerts in your Area |
Like This Article? Read More From Java Code Geeks

Sign me up for the newsletter!
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Join Us

Newsletter
Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.
Email address:
Receive Java & Developer job alerts in your Area
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK