springboot 由 jar包转 war包

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包形式启动的主类

猜你喜欢

转载自blog.csdn.net/l1h2l3/article/details/72724042