包含 zuul 的 gradle 依赖项时出现问题

Trouble while including gradle dependency for zuul

这是我的 build.gradle 文件

buildscript {
    ext {
        springBootVersion = '1.4.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'

jar {
    baseName = 'yBayApplication'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

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

springBoot {
    mainClass = "com.ybayApplication.customerAccount.CustomerServiceApplication"
}

dependencies {
    compile('org.springframework.cloud:spring-cloud-starter-eureka-server:1.2.3.RELEASE')
    compile('org.springframework.cloud:spring-cloud-starter-zuul')
    compile group: 'com.netflix.zuul', name: 'zuul-core', version: '2.0.0-rc.1'
    compile group: 'com.netflix.governator', name: 'governator-archaius', version: '1.6.0'
    compile group: 'io.reactivex', name: 'rxjava-string', version: '0.22.0'
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("com.h2database:h2")
    testCompile("junit:junit")
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.BUILD-SNAPSHOT"
    }
}


eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
    }
}

这是错误消息,我在构建 gradle 时收到。

Gradle Distribution: Local installation at C:\gradle\gradle-3.4.1
Gradle Version: 3.4.1
Java Home: C:\Program Files (x86)\Java\jdk1.8.0_121
JVM Arguments: None
Program Arguments: None
Gradle Tasks: clean build

:clean UP-TO-DATE
:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':detachedConfiguration5'.
> Could not find com.netflix.governator:governator-archaius:1.6.0.
  Searched in the following locations:
      https://repo1.maven.org/maven2/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
      https://repo1.maven.org/maven2/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
      https://repo.spring.io/snapshot/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
      https://repo.spring.io/snapshot/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
      https://repo.spring.io/milestone/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
      https://repo.spring.io/milestone/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
  Required by:
      project :
      project : > com.netflix.zuul:zuul-core:2.0.0-rc.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED
Total time: 1.77 secs

正如您在 build.gradle 文件中看到的那样,我也添加了缺少的依赖项。我打算在 gradle https://spring.io/guides/gs/routing-and-filtering/.

中基于此示例实现 Zuul 过滤器

乍一看,您似乎需要删除
compile group: 'com.netflix.zuul', name: 'zuul-core', version: '2.0.0-rc.1'

compile('org.springframework.cloud:spring-cloud-starter-zuul') 依赖于 zuul 核心,所以它会下载它。

此外,对于 governator-archaius 我没有看到版本 1.6.0。 我想你的意思是 1.16.0。看link这里抓取准确版本https://mvnrepository.com/artifact/com.netflix.governator/governator-archaius

如果这能解决您的问题,请告诉我。