Spring Boot 2-更改Jar名称 [英] Spring Boot 2 - Change Jar Name

查看:335
本文介绍了Spring Boot 2-更改Jar名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Gradle项目中使用Spring Boot 2在Jenkins中进行jar构建,我想更改该jar文件的名称。

I am using Spring Boot 2 in my Gradle project to do a build to jar in Jenkins, and I would like to change the name of that jar file.

默认情况下,Spring Boot 2使用Gradle属性 rootProject.name ,可以在 /settings.gradle 中进行设置。文件。

By default, Spring Boot 2 used the Gradle property rootProject.name, which can be set in the /settings.gradle file.

但是,我想更改jar文件名,而不更改 rootProject.name

However, I would like to change the jar file name, without changing the rootProject.name.

这是我的 bootJar springBoot 部分code> build.gradle 文件:

Here are my bootJar and springBoot sections of the build.gradle file:

bootJar {
  launchScript()
}

springBoot {
  buildInfo {
    properties {
      artifact = "jarName"
      group = "groupName"
      name = "projectName"
      version = "1.0"
    }
  }
}

注意 artifact 未设置罐子名称,正如我期望的那样阅读后,阅读以下内容: https ://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#integrating-with-actuator

Note: artifact is not setting the jar name, as I expected it to, after reading: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#integrating-with-actuator

推荐答案

感谢 @AndyWilkinson 提供的答案!

bootJar {
  baseName "jarName"
  launchScript()
}

springBoot {
  buildInfo {
    properties {
      group = "groupName"
      name = "projectName"
      version = "1.0"
    }
  }
}

这篇关于Spring Boot 2-更改Jar名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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