springboot 由 jar包转 war包

来源:互联网 发布:adobe注册机mac打不开 编辑:程序博客网 时间:2024/06/05 13:22

1.pom.xml文件中将jar改为war
2.在pom.xml的dependencies块中加入下面内容

    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-web</artifactId>    </dependency>    <dependency>        <groupId>org.springframework.cloud</groupId>        <artifactId>spring-cloud-starter-eureka</artifactId>    </dependency>

3.增加类ServletInitializer,继承org.springframework.boot.context.web.SpringBootServletInitializer,重写configure方法,代码如下:

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {      return application.sources(MicroserviceSimpleProviderUserApplication.class);  } 

其中MicroserviceSimpleProviderUserApplication类指的是以jar包形式启动的主类

原创粉丝点击