Start by changing the packaging method in POM.xml to WAR.

Methods a

1. Add the servlet API

2. Remove tomcat from SpringBoot

3. A new class and inherit SpringBootServletInitializer

The demoApplication. class in the red box is a self-starting class.

Way 2

1. Add the servlet API

2. Remove tomcat from SpringBoot (in a different way)

3. A new class and inheritance SpringBootServletInitializer (another way)

The demoApplication.class in the red box is itself.

Package into a WAR package

You can use the maven command MVN clean package

You can also use software packaging, such as right-click the project in Eclipse and select Export… , the following figure