1,修改pom.xml
1 <dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-web</artifactId> 4 <!-- 去除内嵌tomcat --> 5 <exclusions> 6 <exclusion> 7 <groupId>org.springframework.boot</groupId> 8 <artifactId>spring-boot-starter-tomcat</artifactId> 9 </exclusion> 10 </exclusions> 11 </dependency> 12 <!--添加servlet的依赖--> 13 <dependency> 14 <groupId>javax.servlet</groupId> 15 <artifactId>javax.servlet-api</artifactId> 16 <version>3.1.0</version> 17 <scope>provided</scope> 18 </dependency>
2,将打包方式设置成war
<packaging>war</packaging>
3,修改springboot启动类,注释原有代码,添加以下代码
1 public static void main(String[] args) { 2 SpringApplication.run(Application.class, args); 3 } 4 5 @Override 6 protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { 7 return builder.sources(this.getClass()); 8 }
4,添加Tomcat容器,运行
原文地址:https://www.cnblogs.com/3b2414/p/11438070.html
时间: 2024-10-18 02:47:55