tomcat 部署 springboot项目

xiaoxiao2021-02-28  27

简单的只记录流程,和简单的解释。

1、移除springboot默认内嵌的tomcat

找到pom中依赖的spring-boot-starter-web

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency>添加tomcat依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> <finalName>demo</finalName> </build>如果更简单,可以把 <packaging>war</packaging>

注意点一:

我们一定要重写springboot的入口main:

注意点二:

以为springboot默认tomcat是8版本,所以加入我们使用的tomcat版本过低,同样会出现各种奇葩问题,所以,直接使用tomcat8版本,避免一些奇葩问题

转载请注明原文地址: https://www.6miu.com/read-2614017.html

最新回复(0)