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

前端之家收集整理的这篇文章主要介绍了spring – Gradle build不会向包中添加版本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在使用带有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文件

  1. buildscript {
  2. ext {
  3. springBootVersion = '2.0.0.M7'
  4. springCloudVersion = 'Finchley.M5'
  5. gradleDockerVersion = '0.13.0'
  6. }
  7. repositories {
  8. mavenCentral()
  9. maven { url 'https://plugins.gradle.org/m2/' }
  10. maven { url 'https://repo.spring.io/snapshot' }
  11. maven { url 'https://repo.spring.io/milestone' }
  12. maven { url 'https://repo.spring.io/libs-milestone' }
  13. }
  14. dependencies {
  15. classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  16. classpath("gradle.plugin.com.palantir.gradle.docker:gradle-docker:${gradleDockerVersion}")
  17. }
  18. }
  19. apply plugin: 'java'
  20. apply plugin: 'eclipse'
  21. apply plugin: 'com.palantir.docker'
  22. apply plugin: 'org.springframework.boot'
  23. apply plugin: 'io.spring.dependency-management'
  24. jar {
  25. baseName = 'networks'
  26. version = '0.9'
  27. }
  28. group = 'test'
  29. sourceCompatibility = 1.8
  30. targetCompatibility = 1.8
  31. repositories {
  32. mavenCentral()
  33. maven { url 'https://repo.spring.io/snapshot' }
  34. maven { url 'https://repo.spring.io/milestone' }
  35. maven { url 'https://repo.spring.io/libs-milestone' }
  36. }
  37. dependencyManagement {
  38. imports {
  39. mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
  40. }
  41. }
  42. dependencies {
  43. compile 'org.springframework.boot:spring-boot-starter-web'
  44. compile 'org.springframework.boot:spring-boot-starter-data-jpa'
  45. compile 'org.springframework.boot:spring-boot-starter-data-rest'
  46. compile 'org.springframework.boot:spring-boot-starter-json'
  47. compile 'org.springframework.boot:spring-boot-starter-actuator'
  48. compile 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
  49. runtime 'org.springframework.boot:spring-boot-devtools'
  50. runtime 'org.postgresql:postgresql'
  51. testCompile 'org.springframework.boot:spring-boot-starter-test'
  52. testCompile 'junit:junit'
  53. }
  54. docker {
  55. name "${project.group}/${jar.baseName}"
  56. files jar.archivePath
  57. buildArgs(['JAR_FILE': "${jar.archiveName}"])
  58. }
最佳答案
该版本应在jar外指定:

  1. apply plugin: 'java'
  2. apply plugin: 'eclipse'
  3. apply plugin: 'com.palantir.docker'
  4. apply plugin: 'org.springframework.boot'
  5. apply plugin: 'io.spring.dependency-management'
  6. version = "0.9"
  7. jar {
  8. baseName = 'networks'
  9. }

猜你在找的Spring相关文章