gpt4 book ai didi

gradle - Spring Maven Repo和Spring Boot 1.4.x的潜在问题

转载 作者:行者123 更新时间:2023-12-03 04:01:51 28 4
gpt4 key购买 nike

我有一个成功运行几个月的Spring Boot应用程序。我一直在使用带有一些非常基本的依赖项的Spring Boot 1.4.0-BUILD-SNAPSHOT。这是我的build.gradle的样子:

buildscript {
ext {
springBootVersion = '1.4.0.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
baseName = 'test'
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" }
}

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

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'
}
}

task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}

直到2016年6月11日(昨天晚上)为止,此方法都没有任何问题。我可以使用以下命令运行gradle构建,并且一切正常:
$ ./gradlew clean build

但是,我的gradle构建一无所获地停止处理错误,如下所示:
$ ./gradlew build
:compileJava

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not resolve org.springframework.boot:spring-boot-starter-actuator:.
Required by:
:test:unspecified
> Failed to resolve imported Maven boms: Cannot change dependencies of configuration 'detachedConfiguration1' after it has been resolved.
> Could not resolve org.springframework.cloud:spring-cloud-starter-eureka:.
Required by:
:test:unspecified
> Failed to resolve imported Maven boms: Cannot change dependencies of configuration 'detachedConfiguration1' after it has been resolved.
> Could not resolve org.springframework.cloud:spring-cloud-starter-ribbon:.
Required by:
:test:unspecified
> Failed to resolve imported Maven boms: Cannot change dependencies of configuration 'detachedConfiguration1' after it has been resolved.
> Could not resolve org.springframework.boot:spring-boot-starter-web:.
Required by:
:test:unspecified
> Failed to resolve imported Maven boms: Cannot change dependencies of configuration 'detachedConfiguration1' after it has been resolved.

* 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: 4.846 secs

我尝试运行 ./gradlew dependencies来查看依赖错误是什么。这是我发现的:
$ ./gradlew dependencies
... (snipped)
compile - Dependencies for source set 'main'.
Download https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-parent/1.4.0.BUILD-SNAPSHOT/spring-boot-starter-parent-1.4.0.BUILD-20160612.070708-419.pom
Download https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-dependencies/Brixton.BUILD-SNAPSHOT/spring-cloud-dependencies-Brixton.BUILD-20160610.161057-28.pom
Download https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-dependencies-parent/1.1.2.BUILD-SNAPSHOT/spring-cloud-dependencies-parent-1.1.2.BUILD-20160612.192124-248.pom
Download https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-netflix-dependencies/1.1.3.BUILD-SNAPSHOT/spring-cloud-netflix-dependencies-1.1.3.BUILD-20160610.160842-2.pom
+--- org.springframework.boot:spring-boot-starter-actuator: FAILED
+--- org.springframework.cloud:spring-cloud-starter-eureka: FAILED
+--- org.springframework.cloud:spring-cloud-starter-ribbon: FAILED
\--- org.springframework.boot:spring-boot-starter-web: FAILED

compileClasspath - Compile classpath for source set 'main'.
+--- org.springframework.boot:spring-boot-starter-actuator: FAILED
+--- org.springframework.cloud:spring-cloud-starter-eureka: FAILED
+--- org.springframework.cloud:spring-cloud-starter-ribbon: FAILED
\--- org.springframework.boot:spring-boot-starter-web: FAILED

... (same messages repeating for all tasks)

BUILD SUCCESSFUL

Total time: 35.879 secs

经过更多调查后,我发现无法从 repo.spring.io/snapshotrepo.spring.io/milestone下载依赖项(我也尝试过使用 http的URL;同样的问题)。为了排除其他问题,我还尝试了 repo.spring.io/release(带有 httpshttp)-仍然是完全相同的问题。

要解决此问题,我将Spring Boot版本降级到1.3.5.RELEASE(因为它可以从Maven Central存储库中获得,而不必转到Spring的Maven存储库中)。这是更新后的 build.gradle:
buildscript {
ext {
springBootVersion = '1.3.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
baseName = 'test'
version = '0.0.1-SNAPSHOT'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}

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

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-starter-parent:Brixton.RELEASE"
}
}

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'
}
}

task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}

那行得通。幸运的是,我没有使用任何Spring Boot 1.4.x的特定功能,因此构建过程没有任何问题。我测试了我的应用程序,情况看起来还不错。如您所见,我不再使用Spring的存储库,现在我的所有依赖关系都可以通过 mavenCentral()来解决。

所以,我的问题是,如果这是Spring的Maven Repo的问题,怎么会仍然是一个问题(在将近24小时之后),又怎么会没有人报告这个问题?我花了几个小时在谷歌上搜索,但是似乎没有发现任何实质性的注意或担忧。因此,我不确定我是在做一些非常基本的错误,还是我是某种发现者。

最佳答案

请尝试更改mavenBom依赖项,如下所示。我们面临着同样的问题,这对我们有用。

dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Brixton.RELEASE'
}
}

关于gradle - Spring Maven Repo和Spring Boot 1.4.x的潜在问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37778752/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com