Google’s Tomcat 10 supports WebJars, which let you deploy WAR files to your Tomcat 10 server without having to deploy the individual jar files. However, you can’t deploy a WebJar to Tomcat 10 using Spring Boot, as it only supports WebMvc applications. To deploy a Spring Boot app using Tomcat 10, you’ll have to create a WAR file.

Deploying a Spring Boot app to Tomcat is a big deal, since it’s the same process that is the same for deploying a Java war to Tomcat. The first step in deploying a Spring Boot app to Tomcat is to create a Spring Boot app (all the information on how to do that is on the Spring Boot site). The second step is to create a WAR file that is called “tomcat-10-war.war”. This is the file you will deploy to Tomcat.

There are quite a few alternatives when it comes to deploying a Spring Boot Application as a WAR, but none of them are quite so popular as the one we are going to use. I am referring to Java Web Application Project (JWAP), which is a Java-based project management tool.

In this guide, the reader will learn how to implement a Spring Boot REST application on Tomcat 10. According to Apache, the Jakarta EE platform is an evolution of the Java EE platform. Tomcat 10 and later versions implement the specifications developed under Jakarta EE. Tomcat 9 and earlier versions implement the specifications developed in Java EE. For this reason, applications developed for Tomcat 9 and earlier will not work on Tomcat 10. However, there is another way to do this. Java EE-based applications developed for Tomcat 9 and earlier can be placed in the $CATALINA_BASE/webapps-javaee directory. Tomcat automatically converts them to Jakarta EE and copies them to the webapps directory. This conversion is done with the Apache Tomcat to Jakarta EE Migration Tool, which is also available as a standalone download for offline use. To demonstrate how to implement a Spring Boot REST application on a standalone Tomcat 10 server, this is what we will do in this tutorial:

  1. Download and install Apache Tomcat 10,
  2. Create and build a very simple REST Spring Boot application,
  3. Deploy the WAR file on the standalone Tomcat 10.

Installing Tomcat 10

Use the following link to download Tomcat 10. For Windows users, add the following to the environment variables named CATALINA_HOME.

  • C:Program FilesApache Software FoundationTomcat 10.0

To start Tomcat, run the following command from the Windows command line. C:Program FilesApache Software FoundationTomcat 10.0bin>startup If the configuration is correct, the following output is generated after Tomcat starts. C:Program FilesApache Software FoundationTomcat 10.0bin>startup With CATALINA_BASE : C:Program FilesApache Software FoundationTomcat 10.0 With CATALINA_HOME : C:Program FilesApache Software FoundationTomcat 10.0 With CATALINA_TMPDIR : C:Program FilesApache Software FoundationTomcat 10.0temp With JRE_HOME : C:Program FilesJavajdk-11.0.10 Use CLASSPATH : C:Program FilesApache Software FoundationTomcat 10.0binbootstrap.jar;C:Program FilesApache Software FoundationTomcat 10.0bintomcat-july.jar With CATALINA_OPTS : C:Program FilesApache Software FoundationTomcat 10.0bin>

Creating a Spring Boot application

Go to Spring Initializr and create a new project with the dependencies below. Unzip the generated zip folder and import the project into Intellij or your favorite IDE. word-image-878 Set the package type to WAR. War Since we will be using an external Tomcat, add the specified tag to the Tomcat dependency in pom.xml. org.springframework.boot spring-boot-starter-tomcat deployed In the main application, extend the SpringBootServletInitializer and set the @Override method to start the application from Tomcat in the classic way. import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import ; @SpringBootApplication public class Tomcat10Application extends SpringBootServletInitializer {. public static void main(String[] args) {, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(Tomcat10Application.class); } } Creating a user template In the template package, create a user class with the following fields. public class User { private String firstName ; private String lastName ; private String email ; public User(String firstname, String lastname, String email) { this.firstName = firstname; this.lastName = lastname; = email; } // Creation method toString } Creating a User Control Create a UserController class in the controller package and create a User object that will be returned the next time the user makes a request. import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController ; @RestController @RequestMapping(/user) public class UserController {. @GetMapping(/read/one) public String readUser(){ User User = new User(John,doe,[email protected]) ; return user.toString(); } }

Deploy the application on Tomcat 10

Go to the Tomcat installation folder in the main program files area and create a folder named webapps-javaee. word-image-879 On the command line, navigate to the project source and create a WAR file using the following command. mvnw assessment Paste the created WAR file into the webapps-javaee folder, where Tomcat will automatically move and add it to the webapps folder from where it can be deployed to the client. word-image-880 Restart Tomcat and note the following logs when starting the server.

Use of the Jakartaee migration tool

Alternatively, the application can be migrated using the following command. java -jar jakartaee-migration-*-shaded.jar After successfully executing the command, restart Tomcat. word-image-881 After the server reboots, Tomcat automatically migrates the application and adds it to the web apps folder of the Tomcat installation. word-image-882 In your favorite browser, click the following link, which returns the user object created in the controller.

  • HTTP://localhost:8080/tomcat10-0.0.1-SNAPSHOT/user/read/one



In this tutorial, you learned how to deploy a Spring Boot REST application on Tomcat 10 using the standard Tomcat 10 features for migrating Java EE applications. You have seen how Tomcat 10 takes the application behind the scenes and creates an application that can run on Tomcat 10. Have fun coding!This is a blog that tracks the latest trends in the world of Java, Tomcat, Spring and Spring Boot.. Read more about deploy spring boot jar to tomcat and let us know what you think.

Frequently Asked Questions

How do you deploy a spring boot application on Tomcat as a war package?

If you’d like to deploy a Spring Boot application as a WAR file to Tomcat, here’s how you do it. This assumes you have already deployed the application to the cloud, eg, via CloudBees or another PaaS provider. The Spring Boot project is a brand new Java application framework that is an updated version of the Spring Framework. Spring Boot is extremely easy to learn, and is unlike Spring MVC, which requires a special sort of knowledge you gain in order to write an application using Spring MVC. Whereas Spring Boot is fully Java-based, requiring no special Spring Framework experience to learn.

How do I package Spring boot application as war?

Most people nowadays are familiar with the application server that comes bundled with the JDK. One of the main strengths of JDK is the fact that it supports a wide range of technology stack and it has a plug-in architecture – you can extend it with add-ons and use it in a wide variety of scenarios. In addition, it is a very stable and robust technology; it has been around for a long time and has been proven to be reliable and safe. If you want to deploy a Spring Boot application as a WAR to Tomcat 10, here are some simple steps you should follow: 1. Create a WAR file in the WEB-INF folder. 2. Create a Spring Boot application in src/main/resources/ 3. Package the WAR file along with the file. 4. Add the WAR file to the war folder. 5. Add the WAR file to the Tomcat’s webapps folder. 6. Select the WAR file in Tomcat’s tomcat.webapps folder and deploy.

Where do I put war file in tomcat?

Well, the title has an unfortunate typo(not “war” but “war”), but this blog post isn’t about the title, it’s about the content. So let’s find out. Deploying a Spring Boot app as a WAR to a Tomcat application server is easy. All you need to do is follow the steps below and it will be done!

spring boot tomcat configurationspring boot microservices deployment tomcathow to deploy spring boot application in tomcatdeploy spring boot jar to tomcatspring boot production deployment best practiceshow to deploy war files to spring boot embedded tomcat,People also search for,Feedback,Privacy settings,How Search works,how to deploy spring boot war file in external tomcat,spring boot microservices deployment tomcat,how to deploy spring boot application in tomcat,deploy spring boot jar to tomcat,spring boot without embedded tomcat,spring boot war vs jar,how to deploy spring application in tomcat,spring-boot application not starting in tomcat