Netbeans Maven не удалось выполнить цель по проекту - PullRequest
2 голосов
/ 16 января 2020

Я сейчас работаю над проектом 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

Я пытался добавить еще один репозиторий, используя https://repo.maven.apache.org/maven2/ url в моем pom. xml, но ошибка все еще сохраняется. Я пытался решить эту проблему в течение последних 5 часов, было бы здорово, если бы кто-нибудь мог мне помочь, вот мой пом. 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>

Требуется помощь. Заранее спасибо.

Ответы [ 5 ]

19 голосов
/ 17 января 2020
<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>
7 голосов
/ 23 января 2020

Проблема связана с переходом 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, вы можете go to Инструменты-> Параметры -> Java -> Maven и в Maven Home Укажите, где находится ваша установка Maven. Для меня это был / usr / bin / mvn , и мне пришлось определить путь как / usr , так как кажется, что Netbeans ожидает найти каталог с именем bin содержащий исполняемый файл mvn .

Кроме того, в связи с перемещением репозиториев maven для некоторых старых зависимостей мне пришлось использовать конечную точку insecure в моей конфигурации maven:

        <pluginRepository>
            <id>Codehaus repository</id>
            <url>http://insecure.repo1.maven.org/maven2/</url>
        </pluginRepository> 

Просто добавьте это на тот случай, если это кому-нибудь пригодится.

0 голосов
/ 22 апреля 2020

В то время как другие ответы дают вам обходные пути путем ручной настройки хранилища или более поздней версии Maven, истинный источник проблемы состоит в том, что Netbeans (8.2) устарел и больше не обновляется, вам лучше перейти на Apache Netbeans (в настоящее время версия 11.3).

0 голосов
/ 16 января 2020

Я исправил проблему, обновив до последней версии Maven, он начал использовать https вместо http для загрузки всех deps.

0 голосов
/ 16 января 2020

Сегодня я также столкнулся с проблемой команд netbean maven. Я думаю, что есть проблема в сервере. Как ошибка https; 501

...