为春季启动应用程序生成战争

时间:2017-07-16 23:25:48

标签: spring tomcat spring-boot gradle war

我一直在关注spring提供的教程,似乎无法理解为什么我的.war文件为空。点击here查看/下载代码。最终目标是下载此文件,构建.war文件,然后将其部署到我的tomcat服务器。我已将以下内容添加到build.gradle

申请插件:“战争”

但这只会产生一个包含零类文件的战争。

的build.gradle

examTable.addRow(new Object[] { name,headname,datum, exam,pres });

1 个答案:

答案 0 :(得分:4)

对于教程代码,您需要做两件事:

  1. 包装spring-boot ref的war插件:

    apply plugin: 'war'
    
    war {
        baseName = 'gs-spring-boot'
        version =  '0.1.0'
    }    
    
  2. 创建可部署的war文件spring-boot ref

    @SpringBootApplication
    public class Application extends SpringBootServletInitializer {
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(Application.class);
        }
    
  3. 并且还指定了提供的tomcat依赖项:

    dependencies {
        // …
        providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
        // …
    }
    

    这是我的commit reference和结果: result

相关问题