簡體   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