我用gradle编写了一个spring-boot应用程序,它运行正常。
我使用bootRepackage构建了一个胖jar,我添加了maven插件,因此我可以安装jar。
问题是我无法将胖jar安装到maven存储库。
这是我的基础项目的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'
}
答案 0 :(得分:1)
您需要确保bootRepackage
任务在install
之前运行。一种粗略的方法是在命令行中指定两者:
./gradlew bootRepackage install
更好的方法是将install
任务配置为依赖于bootRepackage
任务。您可以将以下内容添加到build.gradle
:
install {
dependsOn bootRepackage
}
使用此配置后,Gradle将在您运行bootRepackage
时自动运行install
。例如:
$ ./gradlew install
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:jar
:bootRepackage
:install
BUILD SUCCESSFUL
Total time: 5.487 secs