[英]spring boot gradle plugin in a multi module project - error finding mainClass
我正在使用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'
}
}
不要在主項目中使用Spring Boot gradle插件,只能在webProject
子模塊中使用。
我在多模塊Spring啟動項目中遇到了類似的問題。 編譯沒有主類的模塊A. 主類在不同的模塊中(模塊B)。
我在該模塊A的build.gradle中添加了一個插件。
apply plugin: 'application'
mainClassName = "module B.ITS_MAIN_CLASS"
然后它工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.