1.修改pom,将打包方式改为war包
2.dependencides中配置外部tomcat
<!--因配置外部TOMCAT 而配置--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
3.添加一个SpringBootServletInitializer 的继承类
package com.vrv.app; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; /** * @Author:LJ * @Description: * @Date: 2018/5/18 * @Modified By: */ public class DemoInitializer extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(HuaxiaApplication.class); } }
4.main主类还是保持不变
package com.vrv.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }