我目前正在构建一个微服务项目,但是当我想构建一个使用来自'core'模块(我的库模块)的类的服务时,gradle在整个地方吐出错误,找不到符号,第一个错误是打印到控制台是'import com.company.core.Remote.Access.LogService'错误:包'com.company.core.Remote.Access'不存在 .

以下是一些代码段 . 也许你可以找到错误 .

settings.gradle [root]

rootProject.name = 'backend'

include ':authentication'
include ':core'
include ':discovery'
include ':gateway'
include ':log'
include ':media'
include ':post'
include ':user'

build.gradle [root]

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.1.RELEASE")
    classpath("io.spring.gradle:dependency-management-plugin:0.6.1.RELEASE")
  }
}

allprojects {
  group = 'com.company.backend'
}

allprojects {
  apply plugin: 'java'
  apply plugin: 'application'
  apply plugin: 'org.springframework.boot'
  apply plugin: 'io.spring.dependency-management'
  repositories {
    mavenCentral()
  }
}

subprojects {
  dependencies{
    compile project(':core')
  }
}

settings.gradle [service1]

rootProject.name = 'backend'

build.gradle [service1]

buildscript {
    ext {
        springBootVersion = '2.0.2.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.company'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


ext {
    springCloudVersion = 'Finchley.BUILD-SNAPSHOT'
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
    compile('org.springframework.cloud:spring-cloud-starter-netflix-zuul')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

settings.gradle [core]

rootProject.name = 'backend'

build.gradle [core]

buildscript {
    ext {
        springBootVersion = '2.0.2.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.company'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

bootJar {
    enabled = false
}

jar {
    enabled = true
}

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


ext {
    springCloudVersion = 'Finchley.BUILD-SNAPSHOT'
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-jdbc')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
    compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server')
    runtime('mysql:mysql-connector-java')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}