Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Gradle多模块项目:将模块依赖关系应用于除自身以外的所有子项目_Spring_Gradle_Circular Dependency_Multi Module_Subproject - Fatal编程技术网

Spring Gradle多模块项目:将模块依赖关系应用于除自身以外的所有子项目

Spring Gradle多模块项目:将模块依赖关系应用于除自身以外的所有子项目,spring,gradle,circular-dependency,multi-module,subproject,Spring,Gradle,Circular Dependency,Multi Module,Subproject,我的应用程序是一个Gradle多模块项目,由多个服务和一个服务公共模块组成 我已经将所有模块共有的所有依赖项都提取到root build.gradle中,并且我还想在所有子项目中包含服务公共模块,这在理论上是可行的,但是我得到了一个循环依赖项问题,因为它本身就包含了 apply plugin: 'java' group = 'com.myapplication' ext { set('springCloudVersion', "2.2.0.RELEASE") set('spr

我的应用程序是一个Gradle多模块项目,由多个服务和一个服务公共模块组成

我已经将所有模块共有的所有依赖项都提取到root build.gradle中,并且我还想在所有子项目中包含服务公共模块,这在理论上是可行的,但是我得到了一个循环依赖项问题,因为它本身就包含了

apply plugin: 'java'

group = 'com.myapplication'

ext {
    set('springCloudVersion', "2.2.0.RELEASE")
    set('springBootVersion', "2.2.2.RELEASE")
}

allprojects {

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

}

buildscript {
    ext {
        springBootVersion = "2.2.2.RELEASE"
    }

    repositories {
        maven { url 'https://repo.spring.io/plugins-snapshot' }
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'io.spring.gradle:dependency-management-plugin:1.0.7.BUILD-SNAPSHOT'
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

subprojects {
    version = '1.0'

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

    ext {
        springCloudVersion = "2.2.0.RELEASE"
        springBootVersion = "2.2.2.RELEASE"
    }

    test {
        useJUnitPlatform()
    }

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

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

    dependencies {
        compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: "${springBootVersion}"
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: "${springBootVersion}"
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: "${springBootVersion}"
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: "${springBootVersion}"
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: "${springBootVersion}"
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: "${springBootVersion}"
        compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging', version: "${springBootVersion}"
        compile group: 'org.springframework.cloud', name: 'spring-cloud-starter', version: "${springCloudVersion}"
        compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-kubernetes', version: '1.1.1.RELEASE'

        compile group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.3.2'

        compile group: 'com.github.piomin', name: 'logstash-logging-spring-boot-starter', version: '1.2.2.RELEASE'

        compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
        compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'

        compileOnly 'org.projectlombok:lombok:1.18.10'
        annotationProcessor 'org.projectlombok:lombok:1.18.10'

        testCompile group: 'com.h2database', name: 'h2', version: '1.4.200'
        compile group: 'org.postgresql', name: 'postgresql', version: '42.2.9'

        testCompile group: 'org.springframework.cloud', name: 'spring-cloud-stream-test-support', version: "${springCloudVersion}"

        implementation project(":service-common")
    }

}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

如何排除服务通用模块的实施项目(“:服务通用”)

subprojects {
    dependencies {
        if (!project.name == "service-common") {
            implementation(project(":service-common"))
        }
    }
}

您可以执行以下操作:

subprojects {
    dependencies {
        if (!project.name == "service-common") {
            implementation(project(":service-common"))
        }
    }
}