First, modify oa credit disk speed controllable platform to build Q848622369 packaged form
Set in the pom.xml
<packaging>war</packaging>
Second, remove the plug embedded tomcat
Found in pom.xml
spring-boot-starter-web
dependency nodes, the following code added thereto,
-
<dependency>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-starter-web</artifactId>
-
<-! Remove embedded tomcat plug-ins ->
-
<exclusions>
-
<exclusion>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-starter-tomcat</artifactId>
-
</exclusion>
-
</exclusions>
-
</dependency>
- =
Third, adding a dependency of servlet-api
The following two methods can, optionally one
-
<dependency>
-
<groupId>javax.servlet</groupId>
-
<artifactId>javax.servlet-api</artifactId>
-
<version>3.1.0</version>
-
<scope>provided</scope>
-
</dependency>
- =
-
<dependency>
-
<groupId>org.apache.tomcat</groupId>
-
<artifactId>tomcat-servlet-api</artifactId>
-
<version>8.0.36</version>
-
<scope>provided</scope>
-
</dependency>
- = Change startup class, and override the initialization method
We usually start with the way the main method, there is a App start classes, as follows:
-
-
public class Application {
-
public static void main(String[] args) {
-
SpringApplication.run(Application.class, args);
-
}
-
}
1
- 2
- 3
- 4
- 5
- 6
- 7
We need a similar arrangement to start web.xml spring context, and add a class SpringBootStartApplication peer Application class, code is as follows:
-
/**
-
* Modify the startup class and override inherited SpringBootServletInitializer configure method
-
*/
-
public class SpringBootStartApplication extends SpringBootServletInitializer {
-
-
-
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
-
// point to note here to start the Application class originally performed by main method
-
return builder.sources(Application.class);
-
Fifth, the deployment package
Under the project root directory (the directory that contains the pom.xml), type in the command line:
mvn clean package
to wait for the completion of packing, there[INFO] BUILD SUCCESS
is the packaging success.
Then the war package under the target directory into the webapps directory of tomcat, tomcat startup, automatically unzip deployment.
Finally, enter in your browser
http://localhost:[端口号]/[打包项目名]/
Successfully posted