1, modify the pom.xml file
① Set packaged form
<packaging>war</packaging>
② remove embedded Tomcat plug-in
before fixing:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
Modified:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- 移除嵌入式tomcat插件 --> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency>
③ dependent added servlet-api
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency>
2, modify the Application startup class
before fixing:
@SpringBootApplication public class KlausApplication { public static void main(String[] args) { SpringApplication.run(KlausApplication.class, args); } }
Modified:
@SpringBootApplication public class KlausApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(KlausApplication.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(KlausApplication.class); } }
3, the external war package into the webapps of tomcat
4, double-click in the bin directory startup.bat outside the Tomcat
5, access: Enter http: // localhost: 8080 / name / address of the interface
Problem Description: SpringBoot deploy the project to Tomcat access 404 interfaces appear cause of the problem: war package name when you enter a project name not address tomcat deployed Solution: Modify address the problem issues address: http: // localhost: 8080 / Klasu / successfully address : http: // localhost: 8080 / klaus-0.0.1-SNAPSHOT /