繁体   English   中英

Spring Boot找不到主类多模块

[英]Spring Boot Can't find main class Multi module

我很难告诉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'
    }

mainClassName应该由包和类名本身组成,因此在您的情况下应为:

mainClassName = 'com.bachadiff.application.Application'

而且,由于您说的是多项目构建,因此应将其放入pictures-service-application项目的build.gradle

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM