【发布时间】:2018-11-01 19:37:30
【问题描述】:
我很难告诉 Spring Main 类的位置。到目前为止,我只设法正确指定它在图片服务模块中的位置(即图片服务/src/main/com.bachadiff.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'
}
【问题讨论】:
-
我对spring一点也不熟悉,但是你试过用
mainClassName = 'com.bachadiff.application.Application'代替吗?您可以通过右键单击所选类然后选择“复制参考”来获取您需要使用的字符串 -
我可以得到字符串,它和你说的完全一样,但是当我把它放在主要的 build.gradle 中时它仍然找不到它。 (mainClassName = com.bachdiff.application.Application,或 mainClassName = pictures-service-applications.com.bachadiff.application.Application)
标签: java spring-mvc spring-boot gradle groovy