springboot-war
Posted yaoyuan2
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot-war相关的知识,希望对你有一定的参考价值。
1、pom.xml
与springboot-jar-web的区别是:
将
<packaging>jar</packaging>
替换成:
<packaging>war</packaging>
2、DemoApplication
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);
3、ServletInitializer
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; public class ServletInitializer extends SpringBootServletInitializer @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) return application.sources(DemoApplication.class);
4、resources下,新建目录
static templates
application.yml、application-dev.yml、DemoApplicationTests.java 与spring-jar相同。
以上是关于springboot-war的主要内容,如果未能解决你的问题,请参考以下文章