![](/img/trans.png)
[英]Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) on project someProject: Could not exec java
[英]Gradle Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE (repo1.maven.org: Nome o servizio sconosciuto)
我在 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.
這是我的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.jackson.core:jackson-core:2.7.3')
compile("org.springframework:spring-jdbc")
compile('com.fasterxml.jackson.core:jackson-databind:2.7.3')
compile('com.fasterxml.jackson.core:jackson-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'
}
由於錯誤告訴您Nome o servizio sconosciuto
,無法通過 DNS 解析repo1.maven.org
。 所以你有一些網絡問題,或者你需要使用一個你沒有為 Gradle 配置的代理服務器。 向您的 IT 支持人員詢問您無法解析主機名的原因。
這可能是網絡問題。 如果沒有,請嘗試以下步驟,因為它解決了我的問題。
由於我也面臨同樣的問題,我嘗試通過更改依賴項來解決它。
這個值給了我一個錯誤。
compile("org.springframework.boot:spring-boot-starter-ws")
這是有效的
compile group: 'org.springframework.boot', name: 'spring-boot-starter-ws', version: '1.4.7.RELEASE'
參考: https : //mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-ws/1.1.8.RELEASE
當我第一次嘗試使用 gradle 3.5 在 IntelliJ 上運行 gradle 時,我遇到了 spring-boot-starter 依賴無法解決的問題,使用我的筆記本電腦不需要代理。
問題不見了:
apply plugin: 'org.springframework.boot'
來自 build.gradle 文件。 一旦包含它,它就會立即下載所有依賴項。
我也遇到過這個問題,但原因與當前接受的答案不同。
就我而言,這是因為包含依賴項的服務器沒有正確傳遞憑據。
憑據是在主機容器上的環境變量中設置的,但不存在於進行調用的子容器中,因此連接在主機容器上運行良好,但因Could not resolve...
錯誤在子容器的問題中列出容器。
這是通過使用-D 選項將MAVEN_USERNAME
和MAVEN_PASSWORD
傳遞給 gradle 來解決的:
$ gradle -DMAVEN_USERNAME=foo -DMAVEN_PASSWORD=bar
您的構建文件沒有 spring boot 插件。
應用插件:
'org.springframework.boot'
如果沒有這個,Spring Boot 的依賴管理系統就會被破壞
這可能是由於網絡問題而發生的。 如果您在代理后面,則在 eclipse 中轉到步驟 1)窗口 -> 首選項 -> 網絡連接,此處提供代理詳細信息(代理、端口號)和步驟 2)檢查 AUTH 框,然后輸入用戶 ID 和密碼。 Step 3) 然后點擊gradle refresh
在我的情況下,這是我檢查身份驗證框並輸入用戶和密碼時的問題,它立即起作用。
每當我第一次嘗試在不同的系統中進行干凈的構建或者您的系統中安裝了多個 java 時,這對我來說都是例行公事。
您可能會面臨存儲庫找不到問題或信任來源問題。 因此,對於兩者而言,以下解決方案的問題應該有效。
通過投資,我發現這是由於您的 Java 無法與給定的存儲庫正確通信。
請按照以下步驟解決此問題。
將 Maven 存儲庫公共證書添加到您的本地 java.ini 文件。
使用正確的名稱和擴展名將文件復制到您的本地文件夾 .cer
下載后,將此文件添加到您的 Java 可信證書中。
keytool -import -trustcacerts -keystore {java_path}/jre/lib/security/cacerts -storepass changeit -noprompt -alias my_alias -file {certificate_path}\\certificates.cer
成功將證書添加到您的 java 后,轉到您的存儲庫
運行以下命令來清理和構建您的 Gradle 項目
gradlew build -x test --refresh-dependencies --stacktrace -Djavax.net.ssl.trustStore={your_java_path}\\jre\\lib\\security/cacerts -Djavax.net.ssl.trustStorePassword=changeit
在這里,在上面的命令中,我們明確提供了 java 證書路徑及其密碼。
在此過程之后,您的干凈構建應該可以工作了。 希望這個答案能幫助其他人。
Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.0
和舊的eclipse 2021-09
遇到了同樣的問題。 對我來說,升級到版本2022-09
解決了這個問題。
(還嘗試先弄亂 Windows 和 CloudFlare WARP 的 dns 設置,但這沒有做任何事情)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.