Spring Boot packaging the project to War

2019-08-20 07:16发布

问题:

I have followed these steps to convert the pacakging from Jar to War.

But when i check my project folder or the build folder that is generated there is no war file generated only a war folder comes with MANIFEST.MF file

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-gradle-packaging

The changes i did in my gradle build file

apply plugin: 'war'

configurations {
    providedRuntime
}


dependencies {      
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')      
}

Added a new ServletInitializer class

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(DemoApplication.class);
    }

}

回答1:

you can use the gradle command assemble in order to build the jar . This should help

gradle assemble