转载自:http://blog.csdn.net/u011493599/article/details/70213352
看了好多帖子都不行,最后这篇帖子解决问题
1、去掉spring-boot-starter-web内置的Tomcat
- <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>
2、修改打包类型
- <packaging>war</packaging>
3、因为要在本地启动,所有添加Tomcatjar包,将scope设置为provided,这样在打war包的时候不会包含这个jar包
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-tomcat</artifactId>
- <scope>provided</scope>
- </dependency>
4、修改启动文件Application继承SpringBootServletInitializer
- @SpringBootApplication
- public class SpringbootApplication extends SpringBootServletInitializer {
5、打包
按照从上到下点一遍,在target下找到war包,放到Tomcat的webapps下,启动Tomcat,然后访问localhost:端口号/war名称/接口,如图: