I am having difficulties telling Spring the location of the Main class. So far I have only managed to correctly specify where it is when it is in pictures-service module (ie, pictures-service/src/main/com.bachadiff.application/Application.java)
This is the file structure.
And this is the main gradle file.
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'
}
The mainClassName
should consist out of the package and the class name itself, so in your case that should be:
mainClassName = 'com.bachadiff.application.Application'
And since you are saying that you have a multi-project build, you should put this in the build.gradle
for the pictures-service-application
project
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.