有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在包含zuul的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

正如你在构建中看到的。gradle文件中,我还添加了缺少的依赖项。我打算基于gradle https://spring.io/guides/gs/routing-and-filtering/中的这个示例实现一个Zuul过滤器


共 (1) 个答案

  1. # 1 楼答案

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

    compile('org.springframework.cloud:spring-cloud-starter-zuul')依赖于zuul core,因此它将下载它

    此外,对于governator-archaius,我没有看到版本1.6.0。 我想你指的是1.16.0。请看这里的链接以获取准确的版本https://mvnrepository.com/artifact/com.netflix.governator/governator-archaius

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