Description
The Spring boot framework was recently started, and spring boot came with a servlet container, discovering that, in addition to running the project in Java mode, the Application.java was deployed in a way that would normally be used to launch a Web project to spring Boot's built-in servlet container, to launch the Spring-boot project as it was published in the same way as a normal Web project under Tomcat, needs to be configured in Eclipse.
Specific Steps
(1). Modify Pom.xml to change the packaging method to war
<packaging>war</packaging>
(2). Version support for Tomcat
<!--to join this when fighting a war package, tell Spring-boot Tomcat about the outside of the jar pack, do not punch in--
<dependency>
<groupId> Org.springframework.boot</groupid>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Add this, without spring-boot the built-in Tomcat library
(3). Modify the Startup class and override the initialization method
We need a configuration similar to Web. XML to start the spring context, add a springbootstartapplication class to the application class, with the following code:
/**
* Modify Startup class, Inherit Springbootservletinitializer and override Configure method
*/Public
class Springbootstartapplication Extends Springbootservletinitializer {
@Override
protected Springapplicationbuilder Configure ( Springapplicationbuilder application) {
return application.sources (Application.class);
}
}
(4). This allows the Spring-boot project to be launched in Eclipse in the same way that a normal Web project is posted to tomcat (recommended to be released to root)
Note: Enter the project root directory (that is, the directory containing the Pom.xml), open the command line and enter it at the command line:
MVN clean packages, waiting to be packaged, the [INFO] BUILD success is packaged successfully.
Then put the war package in the target directory under Tomcat's WebApps directory and launch Tomcat to automatically unzip the deployment.
Finally, enter in the browser
http://localhost:[port number/[Package project name]/