标签:bsp pps file tin pac servlet prot jar sources
spring boot会默认生成Jar包,如果想要生成war包需要修改pom和启动类。
并且,测试的时候发现,部署在apache tomcat 7下会报包含的jar包错误,而在apache tomcat 8下能正常启动访问。
如果再tomcat 7下需要解决war包内的jar包冲突(参考:https://blog.csdn.net/qq_14853889/article/details/80026885)
以下步骤参考: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file
@SpringBootApplication public class DemoApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application){ return application.sources(DemoApplication.class); } public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
<packaging>war</packaging>
为了避免内置servlet容器与要部署war包的servlet容器冲突,将内置的tomcat应用范围设为provided。(参考:https://uule.iteye.com/blog/2087485)
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
注:这个war包依然可以用命令行java -jar xxx.war执行。
Spring boot demo: spring boot生成war包
标签:bsp pps file tin pac servlet prot jar sources
原文地址:https://www.cnblogs.com/jane850113/p/10407669.html