我用gradle编写了一个spring-boot应用程序,它运行正常 .
我使用bootRepackage构建了一个胖jar,我添加了maven插件,所以我可以安装jar .
问题是我无法将胖jar安装到maven存储库 .
-
"bootRepackage"构建那个胖jar文件
-
install依赖于"jar"阶段,因此它构建了一个覆盖胖jar文件的瘦jar
-
将精简jar复制到存储库
这是我的基础项目的gradle脚本,请注意我仍然尝试安装到我的本地存储库(我们是一家新公司,我们仍在构建一个远程存储库)
subprojects {
group 'myGroup'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
sourceCompatibility = 1.8
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:0.5.6.RELEASE'
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE'
classpath 'com.bmuschko:gradle-tomcat-plugin:2.0'
}
}
repositories {
jcenter()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'org.mockito:mockito-all:1.8.4'
compile 'ch.qos.logback:logback-classic:1.1.7'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
}
模块的Gradle脚本:
apply plugin: "io.spring.dependency-management"
apply plugin: "spring-boot"
repositories {
jcenter()
}
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:2.0.3.RELEASE'
}
}
dependencies {
compile "org.springframework:spring-web"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile 'com.netflix.feign:feign-okhttp:8.16.2'
}
1 回答
您需要确保
bootRepackage
任务在install
之前运行 . 一种粗略的方法是在命令行上指定两者:更好的方法是将
install
任务配置为依赖于bootRepackage
任务 . 您可以通过将以下内容添加到build.gradle
来执行此操作:使用此配置后,Gradle将在您运行
install
时自动运行bootRepackage
. 例如: