How to deploy external Tomcat process based on springboot


This article mainly introduces the process analysis of spring boot deployed to external Tomcat in the form of war package. The sample code is introduced in great detail in this article, which has a certain reference learning value for everyone’s study or work. Friends who need it can refer to it

Springboot projects can be packaged as. Jar and. War package files. Jar can be started by using java – jar XX. Jar, and. War can be deployed to Tomcat webapps and started with Tomcat.

Springboot itself is built-in Tomcat. If you want to deploy to external tomcat, you need to make some changes.

1. Change packaging to war in POM file

1 <packaging>war</packaging>

2. Exclude Tomcat in Maven

The first kind

  <exclusions><!--  Remove embedded Tomcat plug-in -- >

The second kind

<!--  If a third-party Tomcat is used, please add scope -- >

3. Inherit springbootservletinitializer from and rewrite the configure method

public class DemoApplication extends SpringBootServletInitializer {

  public static void main(String[] args) {, args);

  protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    return builder.sources(DemoApplication.class);

4. Use MVN clean package or editor to package as war package

The above is the whole content of this article, I hope to help you learn, and I hope you can support developer more.

Recommended Today

Mongodb aggregate Mongodb aggregate   1、 Foundation 1. What is aggregation? Aggregation is an aggregation pipeline based on data processing. Each document passes through a pipeline composed of multiple stagesIt can group and filter the pipelines in each stage, and then output the corresponding results after a series of processing DB. Set name. Aggregate ({pipeline: […]