Java Gradle 无法解析 org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE (repo1.maven.org: Nome o servizio sconosciuto)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41979802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gradle Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE (repo1.maven.org: Nome o servizio sconosciuto)
提问by sgargel
I have a problem running a gradle build on Jenkins: Gradle version is https://services.gradle.org/distributions/gradle-2.14.1-bin.zip
我在 Jenkins 上运行 gradle 构建时遇到问题:Gradle 版本是https://services.gradle.org/distributions/gradle-2.14.1-bin.zip
FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'myApp'. > Could not resolve all dependencies for configuration ':classpath'. > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE. Required by: :myApp:unspecified > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE. > Could not get resource 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.4.2.RELEASE/spring-boot-gradle-plugin-1.4.2.RELEASE.pom'. > Could not HEAD 'https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/1.4.2.RELEASE/spring-boot-gradle-plugin-1.4.2.RELEASE.pom'. > repo1.maven.org: Nome o servizio sconosciuto * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
This is my build.gradlefile:
这是我的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-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
war {
baseName = 'myApp'
version = '1.0.5'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
compile('org.springframework.boot:spring-boot-starter-security')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter-web')
compile('com.fasterxml.Hymanson.core:Hymanson-core:2.7.3')
compile("org.springframework:spring-jdbc")
compile('com.fasterxml.Hymanson.core:Hymanson-databind:2.7.3')
compile('com.fasterxml.Hymanson.core:Hymanson-annotations:2.7.3')
compile files('src/main/resources/static/lib/ojdbc7.jar')
// https://mvnrepository.com/artifact/org.json/json
compile group: 'org.json', name: 'json', version: '20080701'
}
采纳答案by Vampire
As the error tells you Nome o servizio sconosciuto
, repo1.maven.org
cannot be resolved via DNS. So you have some networking problem or you need to use a proxy server which you did not configure for Gradle. Ask your IT support as to why you cannot resolve the hostname.
正如错误告诉您的那样Nome o servizio sconosciuto
,repo1.maven.org
无法通过 DNS 解析。所以你有一些网络问题,或者你需要使用一个你没有为 Gradle 配置的代理服务器。向您的 IT 支持人员询问您无法解析主机名的原因。
回答by Seamus Dillon
Your build file does not have the spring boot plugin.
您的构建文件没有 spring boot 插件。
apply plugin:
应用插件:
'org.springframework.boot'
Without this the dependency management system is broken for Spring boot
如果没有这个,Spring Boot 的依赖管理系统就会被破坏
回答by Abhishek
I was getting spring-boot-starter dependency cant be resolved issue when i tried to run gradle first time on IntelliJ using gradle 3.5 using my laptop no proxy required.
当我第一次尝试使用 gradle 3.5 在 IntelliJ 上运行 gradle 时,我遇到了 spring-boot-starter 依赖无法解决的问题,使用我的笔记本电脑不需要代理。
The issue was missing:
问题不见了:
apply plugin: 'org.springframework.boot'
from the build.gradle file. Once included it downloaded all the dependencies in a flash.
来自 build.gradle 文件。一旦包含它,它就会立即下载所有依赖项。
回答by rahulnikhare
This is might be a network issue. If not then please try below steps as it solved my issue.
这可能是网络问题。如果没有,请尝试以下步骤,因为它解决了我的问题。
As I was also facing the same problem, I tried to solve it by changing the dependencies.
由于我也面临同样的问题,我尝试通过更改依赖项来解决它。
This value gives me an error.
这个值给了我一个错误。
compile("org.springframework.boot:spring-boot-starter-ws")
This is what works
这是有效的
compile group: 'org.springframework.boot', name: 'spring-boot-starter-ws', version: '1.4.7.RELEASE'
Ref:https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-ws/1.1.8.RELEASE
参考:https: //mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-ws/1.1.8.RELEASE
回答by Taylor Edmiston
I experienced this issue as well but for a different reason than the currently accepted answer.
我也遇到过这个问题,但原因与当前接受的答案不同。
In my case, it was that the server housing the dependencies was not being passed the credentials properly.
就我而言,这是因为包含依赖项的服务器没有正确传递凭据。
The credentials were set in environment variables on a host container but not present in a child container making the call, so the connection worked fine on the host container, but failed with the Could not resolve...
errors listed in the question on the child container.
凭据是在主机容器上的环境变量中设置的,但不存在于进行调用的子容器中,因此连接在主机容器上运行良好,但Could not resolve...
由于子容器上的问题中列出的错误而失败。
This was resolved by passing MAVEN_USERNAME
and MAVEN_PASSWORD
to gradle using -D options:
这是通过使用-D 选项传递MAVEN_USERNAME
和MAVEN_PASSWORD
gradle 来解决的:
$ gradle -DMAVEN_USERNAME=foo -DMAVEN_PASSWORD=bar