我正在使用Spring启动gradle插件版本1.5.1 RELEASE如下所示。在webProject的构建失败抱怨丢失属性'mainClass',并且只在我运行'webProject:build'时有效。这是预期的用法吗?在多模块项目中的弹簧启动gradle插件 - 错误发现mainClass
编辑:更新了构建脚本并从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'
}
}
虽然这个回应解决了我的问题,但我最终还是对所有模块使用了spring boot。试过了luboskmac的建议,但没有运气。最终没有使用bootRun。谢谢 – patb23