Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot application in windows server

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?

like image 261
Kiran Kumar Avatar asked Aug 12 '16 00:08

Kiran Kumar


People also ask

Which server is best for spring boot?

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.


2 Answers

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.

like image 66
Shawn Clark Avatar answered Sep 19 '22 13:09

Shawn Clark


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.

like image 27
Joao Vitor Marques Avatar answered Sep 18 '22 13:09

Joao Vitor Marques