springboot jar包转war包

1.POM添加打包方式:<packaging>war</packaging>
2.POM添加依赖:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

3.添加类:ServletInitializer

package xxxx;

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(XXXApplication.class);
    }

}

猜你喜欢

转载自blog.csdn.net/hqqqqqqq555/article/details/106812053