如何在Spring Boot中创建一个可执行jar? [英] How do I create an an executable jar in Spring Boot?

查看:108
本文介绍了如何在Spring Boot中创建一个可执行jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Spring Boot 1.5.2和Spring Tool Suite中的Gradle Buildship的Spring MVC项目.

I have a Spring MVC project using Spring Boot 1.5.2 with Gradle Buildship in Spring Tool Suite.

  1. 如何仅从源代码创建JAR文件,该文件将在另一台服务器中运行并在其中下载所需的依赖项?
  2. 如何使用所有源文件和依赖项创建胖JAR?

我的gradle.build文件是:

buildscript {
    ext {
        springBootVersion = '1.5.2.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
mainClassName = "com.jtv.elastic.mvc.ElasticSpringApplication"    
sourceCompatibility = 1.8
repositories {
    mavenCentral()
}    
dependencies {
    compile('org.springframework.boot:spring-boot-starter-web') 
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

推荐答案

您应将bootRepackage任务用于gradle.更多信息

You should use bootRepackage task for gradle. More information here and here

这篇关于如何在Spring Boot中创建一个可执行jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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