[英]Netbeans Maven Failed to execute goal on project
我目前正在處理一個 Java 項目,我的問題有點奇怪,因為昨天我的代碼運行良好,然后今天突然當我嘗試構建和測試我的代碼時,我收到此錯誤:
Failed to execute goal on project extraportGlobalSearch: Could not resolve dependencies for project com.api:extraportGlobalSearch:jar:1.0: Failed to collect dependencies for [org.glassfish.jersey.containers:jersey-container-grizzly2-http:jar:2.27 (compile), org.glassfish.jersey.inject:jersey-hk2:jar:2.27 (compile), junit:junit:jar:4.9 (test), com.googlecode.json-simple:json-simple:jar:1.1.1 (compile), com.fasterxml.jackson.core:jackson-annotations:jar:2.5.4 (compile), javax.servlet:javax.servlet-api:jar:3.0.1 (compile), com.google.zxing:core:jar:3.3.3 (compile), com.fasterxml.jackson.core:jackson-databind:jar:2.5.4 (compile), oracle:ojdbc:jar:11.2.0.4 (compile), org.glassfish.grizzly:grizzly-http-server:jar:2.4.0 (compile)]: Failed to read artifact descriptor for oracle:ojdbc:jar:11.2.0.4: Could not transfer artifact oracle:ojdbc:pom:11.2.0.4 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/oracle/ojdbc/11.2.0.4/ojdbc-11.2.0.4.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
我嘗試在我的 pom.xml 中使用https://repo.maven.apache.org/maven2/ url 添加另一個 repo,但錯誤仍然存在。 在過去的 5 個小時里,我一直試圖解決這個問題,如果有人能幫助我,那就太好了,這是我的 pom.xml:
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.api </groupId>
<artifactId>extraportGlobalSearch</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>extraportGlobalSearch</name>
<repositories>
<repository>
<id>apache2-https</id>
<name>Apache 2 https</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<!-- uncomment this to get JSON support:
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
</dependency>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.5.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>11.2.0.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-server</artifactId>
<version>2.4.0</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.api.GlobalSearch.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<jersey.version>2.27</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
需要幫助。 提前致謝。
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
該問題僅與 maven 遷移到 https 有關:https: //blog.sonatype.com/central-repository-moving-to-https
我發現我的問題是 Netbeans (8.2) 被設置為使用捆綁的 maven 可執行文件 (3.0.5)。 此版本的 maven 已過時,不會自動訪問 https 存儲庫。
我安裝了一個較新的版本(Apache Maven 3.5.4 (Red Hat 3.5.4-5) ),它通過在我的項目目錄中執行mvn clean install
來工作。
要讓 Netbeans 使用不同版本的 maven,您可以轉到Tools->Options->Java->Maven並在Maven Home 中指向您的 maven 安裝所在的位置。 對我來說,它是/usr/bin/mvn ,我必須將路徑定義為/usr ,因為 Netbeans 似乎希望找到一個名為bin的目錄,該目錄包含mvn可執行文件。
此外,與 maven 移動存儲庫相關,對於某些舊的依賴項,我必須在我的 maven 配置中使用現在不安全的端點:
<pluginRepository>
<id>Codehaus repository</id>
<url>http://insecure.repo1.maven.org/maven2/</url>
</pluginRepository>
只是添加這個以防它對任何人有用。
您應該更新您的 maven 版本,最后一個 maven 版本使用 https。
我通過更新到最新的 maven 版本解決了這個問題,它開始使用 https 而不是 http 來下載所有的 deps。
雖然其他響應通過手動配置存儲庫或更新版本的 Maven 為您提供了解決方法,但問題的真正根源是 Netbeans (8.2) 已過時且不再更新,您最好遷移到 Apache Netbeans (目前為 11.3 版)。
我更改了全局 netbeans 配置工具的maven 版本工具-> 選項 -> Java -> Maven -> Maven 主頁並瀏覽您的 Windows 系統的 maven 安裝(例如 maven3.6),我認為 maven 版本嵌入 netbeans 8.2 需要更新
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.