Spring Boot将项目打包到War中 [英] Spring Boot packaging the project to War

查看:88
本文介绍了Spring Boot将项目打包到War中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照以下步骤将装甲兵从Jar转换为War.

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

但是当我检查项目文件夹或生成的生成文件夹时,没有生成任何war文件,而MANIFEST.MF文件仅带有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

我在gradle构建文件中所做的更改

The changes i did in my gradle build file

apply plugin: 'war'

configurations {
    providedRuntime
}


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

添加了一个新的ServletInitializer类

Added a new ServletInitializer class

public class ServletInitializer extends SpringBootServletInitializer {

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

}

推荐答案

您可以使用gradle命令进行汇编以构建jar.这应该有帮助

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

gradle assemble

这篇关于Spring Boot将项目打包到War中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆