我很难告诉 Spring Main 类的位置。到目前为止,我只设法正确指定它在图片服务模块中的位置(即图片服务/src/main/com.bachdiff.application/Application.java)
这是文件结构。
这是主要的 gradle 文件。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE")
}
}
plugins {
id 'java'
id 'java-library'
id 'idea'
id "org.springframework.boot" version "2.0.2.RELEASE"
id "io.spring.dependency-management" version "1.0.5.RELEASE"
}
bootJar {
baseName = 'com.bachadiff.pictures-service'
version = '0.1.0'
mainClassName = 'com.bachadiff.application.Application'
}
version = '0.1.0'
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext.common = [
spring_web : 'org.springframework.boot:spring-boot-starter-web:2.0.2.RELEASE',
spring_rest : 'org.springframework.boot:spring-boot-starter-data-rest:2.0.2.RELEASE',
spring_mongo: 'org.springframework.boot:spring-boot-starter-data-mongodb:2.0.2.RELEASE',
spring_test : 'org.springframework.boot:spring-boot-starter-test'
]
ext.test = [
junit: 'junit:junit:4.12'
]
dependencies {
api 'org.springframework.boot:spring-boot-starter-web:2.0.2.RELEASE'
api 'org.springframework.boot:spring-boot-starter-data-rest:2.0.2.RELEASE'
api 'org.springframework.boot:spring-boot-starter-data-mongodb:2.0.2.RELEASE'
compile project(':pictures-service-impl')
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
最佳答案
mainClassName
应该由包和类名本身组成,所以在你的情况下应该是:
mainClassName = 'com.bachadiff.application.Application'
既然你说你有一个多项目构建,你应该把它放在
build.gradle
对于pictures-service-application
项目
关于java - Spring Boot找不到主类多模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50477773/