I am planning to deploy a web application built on spring boot in windows server.
I want to use tomcat container.
Can I deploy the spring boot fat jar directly or is it recommended to deploy the war file.
please suggest how to deploy and the preferred method?
By default, Spring Boot uses Tomcat 7. If you want to use Tomcat 8, just say so! You need only override the Maven build's tomcat. version property and this will trigger the resolution of later builds of Apache Tomcat.
As Josh Long likes to say "Make Jar not War!" It really allows an application to have flexibility on where it can be run and allows for everything to be packaged as one artifact. Windows has no issue running the embedded Tomcat that is part of Spring Boot and that is exactly what it is doing when running it in your IDE. The one edge case to this is keeping the process running on the server. Normally in Windows you would do that by setting up a service and having that service run java -jar myapp.jar
. I haven't personally seen it done so might take some playing around but it is possible.
A simple way to run a spring application in Windows Server is to run it as a service. You can do it using the winsw, that you download its .bin file here winws download
Then, rename it to something like my-app.exe and create a XML file like this:
<service>
<id>my-app-service</id>
<name>my-app-service</name>
<description>Back end service for app</description>
<env name="HOME" value="YOUR_JAR_FILE_PATH"/>
<executable>java</executable>
<arguments>-Xrs -Xmx256m -jar "YOUR_JAR_FILE_PATH\YOUR_JAR_FILE.jar"</arguments>
<logmode>rotate</logmode>
</service>
Then, using the terminal, run:
my-app.exe install service
Your application is now a windows service and you can start\stop it in the tasks manager on the services tab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With