加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

spring – Gradle build不会向包中添加版本

发布时间:2020-12-15 01:46:58 所属栏目:大数据 来源:网络整理
导读:我正在使用带有Gradle 4.2的Spring Boot 2.0.0.M7创建一个REST微服务. 当我从Eclipse构建或从控制台./gradlew构建运行时,build / libs中生成的包被命名为$app.jar而不是$app- $version.jar. 我错过了什么?我的build.gradle与Spring Boot Docker GS指南相同,

我正在使用带有Gradle 4.2的Spring Boot 2.0.0.M7创建一个REST微服务.
当我从Eclipse构建或从控制台./gradlew构建运行时,build / libs中生成的包被命名为$app.jar而不是$app- $version.jar.

我错过了什么?我的build.gradle与Spring Boot Docker GS指南相同,这个问题阻止了生成docker镜像,因为无法找到jar.

这是我的build.gradle文件:

buildscript {
    ext {
        springBootVersion = '2.0.0.M7'
        springCloudVersion = 'Finchley.M5'
        gradleDockerVersion = '0.13.0'
    }
    repositories {
        mavenCentral()
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'https://repo.spring.io/snapshot' }
        maven { url 'https://repo.spring.io/milestone' }
        maven { url 'https://repo.spring.io/libs-milestone' }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("gradle.plugin.com.palantir.gradle.docker:gradle-docker:${gradleDockerVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.palantir.docker'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

jar {
    baseName = 'networks'
    version = '0.9'
}

group = 'test'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
    maven { url 'https://repo.spring.io/snapshot' }
    maven { url 'https://repo.spring.io/milestone' }
    maven { url 'https://repo.spring.io/libs-milestone' }
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.springframework.boot:spring-boot-starter-data-jpa'
    compile 'org.springframework.boot:spring-boot-starter-data-rest'
    compile 'org.springframework.boot:spring-boot-starter-json'
    compile 'org.springframework.boot:spring-boot-starter-actuator'
    compile 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'

    runtime 'org.springframework.boot:spring-boot-devtools'
    runtime 'org.postgresql:postgresql'

    testCompile 'org.springframework.boot:spring-boot-starter-test'
    testCompile 'junit:junit'
}

docker {
    name "${project.group}/${jar.baseName}"
    files jar.archivePath
    buildArgs(['JAR_FILE': "${jar.archiveName}"])
}
最佳答案
该版本应在jar外指定:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.palantir.docker'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

version = "0.9"

jar {
    baseName = 'networks'
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读