springboot项目部署到tomcat

更新时间: 2020/7/5 8:58:11     点击率: 576

1.修改打包标识,增加行 <packaging>war</packaging>:

   

<groupId>com.dev.warehouse</groupId>
  <artifactId>warehouseSys</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

2.排除内置的tomcat,增加:

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-tomcat</artifactId>
		<scope>provided</scope>
	</dependency>
3.修改启动类或者添加子类ServletInitializer,因为springboot项目没有 web.xml
 
public class ServletInitializer extends SpringBootServletInitializer {

   @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(JxcApplication.class);  }

}