Search code examples
javaspring-bootspring-mvctomcatwar

Is it possible to make a Spring MVC web app run as a "standalone executable" with Java and Tomcat embedded?


I have a web app built with Java, Spring MVC, and JDBC. The result is a WAR file.

To run it, the user has to install Java 8 JDK and Tomcat, and deploy the WAR file to the Tomcat server.

It would be great if they could just download the one file run it as a standalone application.

That is, run "the WAR file" and just browse to http://localhost:8080/myapp

Also, on Windows it would be great it was setup as a Server (like Tomcat is when installed with the installer).

Is there any way to do this? Maybe with Spring Boot or something new like that?


Solution

  • Yep, Spring boot is the way to go. It allows you to build an executable Jar with all dependencies and a Tomcat (by default, can be changed) embedded. But users will still need to download a JRE to execute the Jar, and a database if it's required, but you can use en embedded database like H2, HSQLDB..., depends what is your needs.