包括zuul的gradle依赖性时遇到麻烦

时间:2017-05-03 21:14:27

标签: java gradle build.gradle netflix-zuul spring-cloud-netflix

这是我的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过滤器。

1 个答案:

答案 0 :(得分:1)

首先看,你需要删除
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。请查看此处的链接以获取准确的版本https://mvnrepository.com/artifact/com.netflix.governator/governator-archaius

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