【发布时间】:2017-06-27 15:18:09
【问题描述】:
我使用的是Spring boot gradle插件版本1.5.1 RELEASE,如下图。构建在 webProject 时失败,抱怨缺少属性“mainClass”,并且仅在我运行“webProject:build”时才有效。这是预期的用法吗?
编辑:更新了构建脚本并从 allProjects 中删除了“spring-boot”插件。不得不在 web 项目中添加“bootRepackage”,因为它在这一步失败了——同样的错误。添加“bootRepackage”没有帮助。
buildscript {
ext {
springBootVersion = '1.5.1.RELEASE'
}
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.1.RELEASE")
}
}
plugins {
id 'org.springframework.boot' version '1.5.1.RELEASE'
}
defaultTasks 'clean', 'build'
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = 1.7
targetCompatibility = 1.7
allprojects {
apply plugin: 'java'
//apply plugin: 'org.springframework.boot' -- Commented out based on the answer
repositories {
mavenLocal()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
//all dependencies
}
}
project('aProject') {
dependencies {
compile(project(':bProject'))
}
}
project('webProject') {
apply plugin: 'war'
apply plugin: 'org.springframework.boot'
war {
baseName = 'webProject'
version = '1.0.0-SNAPSHOT'
}
dependencies {
compile(project(':aproject'))
compile(project(':bProject'))
compile 'org.springframework.boot:spring-boot-starter-tomcat'
}
springBoot {
mainClass = 'com.abc.SomeApplication'
}
bootRepackage{
enabled = false
mainClass = 'com.abc.SomeApplication'
}
}
【问题讨论】:
标签: java spring gradle spring-boot build