简体   繁体   English

无法解决项目 Maven 的依赖关系

[英]Could Not Resolve Dependencies For Project Maven

I'm trying to run a GitHub repo that uses Java and Maven, but I ran into an error while using mvn clean install .我正在尝试运行使用 Java 和 Maven 的 GitHub 存储库,但我在使用mvn clean install时遇到了错误。 I would ask this question in the GitHub thread (linked below), but the author hasn't responded to previous issues.我会在 GitHub 线程(链接如下)中问这个问题,但作者没有回复以前的问题。 When I run the command I get this error:当我运行命令时,我收到此错误:

Failed to execute goal on project tu: Could not resolve dependencies for project com.vaguehope.tu:tu:jar:1.1-SNAPSHOT: Failed to collect dependencies at args4j:args4j:jar:2.0.21: Failed to read artifact descriptor for args4j:args4j:jar:2.0.21: Could not transfer artifact args4j:args4j:pom:2.0.21 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [maven.jenkins-ci.org (http://maven.jenkins-ci.org/content/repositories/releases/, default, releases)] -> [Help 1]

Here is the pom file:这是pom文件:

<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.vaguehope.tu</groupId>
    <artifactId>tu</artifactId>
    <version>1.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>tu</name>

    <properties>
        <java.version>1.7</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <args4j.version>2.0.21</args4j.version>
        <commonsio.version>2.4</commonsio.version>
        <logback.version>1.0.9</logback.version>
        <slf4j.version>1.7.2</slf4j.version>
        <junit.version>4.11</junit.version>
        <hamcrest.version>1.3</hamcrest.version>
        <mockito.version>1.9.5</mockito.version>
        <powermock.version>1.5</powermock.version>
    </properties>

    <prerequisites>
        <maven>2.2.1</maven>
    </prerequisites>

    <build>
        <plugins>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.vaguehope.tu.Main</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>assembly</id>
                        <phase>install</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <repositories>

        <repository>
            <id>maven.jenkins-ci.org</id>
            <url>http://maven.jenkins-ci.org/content/repositories/releases/</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

    </repositories>

    <dependencies>

        <!-- CLI -->

        <dependency>
            <groupId>args4j</groupId>
            <artifactId>args4j</artifactId>
            <version>${args4j.version}</version>
        </dependency>

        <!-- Util -->

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commonsio.version}</version>
        </dependency>

        <!-- Logging -->

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <!-- Testing. -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>${powermock.version}</version>
            <scope>test</scope>
        </dependency>


    </dependencies>

</project>

Here is the original GitHub post:这是原始 GitHub 帖子:
https://github.com/haku/tu https://github.com/haku/tu

Seems the repository URL is not accessible.似乎无法访问存储库 URL 。

Try updating the repo URL to maven central:尝试将存储库 URL 更新为 maven 中央:

https://repo1.maven.org/maven2

Remove the repositories tag basically from pom.xml .基本上从pom.xml中删除存储库标签。
Share settings.xml if it doesn't help.如果没有帮助,请分享settings.xml

The problem is that HTTP repositories are blocked by default since this change to Maven .问题是 HTTP 存储库默认被阻止,因为此更改为 Maven Maven developers are trying to force people to use HTTPS. Maven 开发人员正试图强迫人们使用 HTTPS。 This happened a long time after that repo was last touched 4 years ago, which is why the original authors had no problems.这发生在 4 年前最后一次触及该 repo 之后很长时间,这就是为什么原作者没有问题的原因。 See also: How to disable maven blocking external HTTP repositores?另请参阅: 如何禁用 maven 阻止外部 HTTP 存储库?

It seems maven.jenkins-ci.org doesn't exist any more anyway.似乎 maven.jenkins-ci.org 无论如何都不存在了。 You can trivially remove the whole dependency on that repo by bumping this version from 2.0.21 to 2.0.22.您可以通过将此版本从 2.0.21 升级到 2.0.22 来轻松删除对该存储库的整个依赖关系。 The latter exists in Maven Central, and the former does not - hence why the original author(s) needed to add a separate repo declaration to get it from somewhere else.后者存在于 Maven Central 中,而前者不存在 - 因此原作者需要添加单独的 repo 声明才能从其他地方获取它。

<args4j.version>2.0.22</args4j.version>

Then you can delete the whole <repositories> section然后你可以删除整个<repositories>部分

<repositories>
    <repository>
        <id>maven.jenkins-ci.org</id>
        <url>http://maven.jenkins-ci.org/content/repositories/releases/</url>
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

A different solution, related to a corporate environment, is that we are slowly moving out of maven to another dep/build tool, but there is still a 'corporate' settings.xml file defined.与企业环境相关的另一种解决方案是,我们正在慢慢地从 maven 转移到另一个开发/构建工具,但仍然有一个“企业” settings.xml 。定义了 xml 文件。

So just rename it to a different file (instead of deleting), like mv settings.xml settings-backup.xml , and returning maven again, would help you to check if it's the issue.因此,只需将其重命名为不同的文件(而不是删除),例如mv settings.xml settings-backup.xml ,然后返回 Z402C5D9AF6B43711EA070BEE5170F74D ,如果再次检查它会帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM