项目组项目升级springBoot 遇到的问题记录
开发工具:idea 2020.1
springBoot : 2.0.2.RELEASE
hibernate 版本:5.2.17
spring : 5.0.6.RELEASE
1.项目需要使用war包形式部署(现场需要),故需要将SpringBoot 内置的tomcat 排除
1 <dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-web</artifactId> 4 <exclusions> 5 <exclusion> 6 <groupId>org.springframework.boot</groupId> 7 <artifactId>spring-boot-starter-tomcat</artifactId> 8 </exclusion> 9 </exclusions> 10 </dependency>
使用外置的tomcat 运行项目,需要调整启动类(需要继承 SpringBootServletInitializer):
@SpringBootApplication @EnableTransactionManagement public class Application extends SpringBootServletInitializer implements WebApplicationInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } }