简体   繁体   English

Maven 在错误的存储库中搜索工件

[英]Maven searching artifact in wrong repository

I have been getting this error (out of nowhere quite frankly) when trying to build my Java project (Minecraft plugin).在尝试构建我的 Java 项目(Minecraft 插件)时,我一直收到这个错误(坦率地说是突然出现的)。

I have tried searching similar errors up, most I could find were involving mirrors (something I don't use (I think)), the others didn't really have a solution / clear reply.我试过搜索类似的错误,我能找到的大多数都涉及镜子(我不使用的东西(我认为)),其他人并没有真正的解决方案/明确答复。

The error I get:我得到的错误:

[ERROR] Failed to execute goal on project HeroicScoreboard: Could not resolve dependencies for project com.dbsoftwares.spigot:HeroicScoreboard:jar:1.0.0-SNAPSHOT: Could not find artifact com.comphenix.protocol:ProtocolLib:jar:4.5.1-20200112.025312-289 in aikar (https://repo.aikar.co/content/groups/aikar/) -> [Help 1]

完整错误的图像

I get this error both locally and on GitHub ( you can find the build here )我在本地和 GitHub 上都收到此错误( 您可以在此处找到构建

This is the POM file I'm currently using ( you can also find it on github ):这是我目前使用的 POM 文件( 你也可以在 github 上找到):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.dbsoftwares.spigot</groupId>
    <artifactId>HeroicScoreboard</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <repositories>
        <repository>
            <id>centrixpvp</id>
            <url>http://nexus.diviwork.nl/repository/centrix-releases/</url>
        </repository>
        <repository>
            <id>dbsoftwares</id>
            <url>http://nexus.diviwork.nl/repository/dbsoftwares/</url>
        </repository>
        <repository>
            <id>dmulloy2-repo</id>
            <url>https://repo.dmulloy2.net/nexus/repository/public/</url>
        </repository>
        <repository>
            <id>aikar</id>
            <url>https://repo.aikar.co/content/groups/aikar/</url>
        </repository>
        <repository>
            <id>mvdw-software</id>
            <url>http://repo.mvdw-software.be/content/groups/public/</url>
        </repository>
        <repository>
            <id>placeholderapi</id>
            <url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
        </repository>
        <repository>
            <id>viaversion</id>
            <url>https://repo.viaversion.com/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.15.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.dbsoftwares.centrixcore</groupId>
            <artifactId>spigot</artifactId>
            <version>2.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.dbsoftwares.configuration</groupId>
            <artifactId>ConfigurationAPI</artifactId>
            <version>1.3.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>co.aikar</groupId>
            <artifactId>acf-paper</artifactId>
            <version>0.5.0-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.comphenix.protocol</groupId>
            <artifactId>ProtocolLib</artifactId>
            <version>4.5.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>be.maximvdw</groupId>
            <artifactId>MVdWPlaceholderAPI</artifactId>
            <version>3.0.2-SNAPSHOT</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.spigotmc</groupId>
                    <artifactId>spigot</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>me.clip</groupId>
            <artifactId>placeholderapi</artifactId>
            <version>2.9.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.12.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>us.myles</groupId>
            <artifactId>viaversion</artifactId>
            <version>2.2.3</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>HeroicScoreboard v${project.version}</finalName>

        <plugins>
            <plugin>
                <version>3.8.1</version>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <dependencyReducedPomLocation>
                        ${project.build.directory}/dependency-reduced-pom.xml
                    </dependencyReducedPomLocation>
                    <relocations>
                        <relocation>
                            <pattern>co.aikar.commands</pattern>
                            <shadedPattern>com.dbsoftwares.spigot.acf</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>com.dbsoftwares.configuration</pattern>
                            <shadedPattern>com.dbsoftwares.spigot.scoreboard.configuration</shadedPattern>
                        </relocation>
                        <relocation>
                            <pattern>org.jsoup</pattern>
                            <shadedPattern>com.dbsoftwares.spigot.scoreboard.jsoup</shadedPattern>
                        </relocation>
                    </relocations>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
</project>

So it basically searches the 'ProtocolLib' artifact in this repository:所以它基本上在这个存储库中搜索“ProtocolLib”工件:

        <repository>
            <id>aikar</id>
            <url>https://repo.aikar.co/content/groups/aikar/</url>
        </repository>

instead of this one (where it's located):而不是这个(它所在的位置):

        <repository>
            <id>dmulloy2-repo</id>
            <url>https://repo.dmulloy2.net/nexus/repository/public/</url>
        </repository>

Edit #1: I forgot to mention that yes, I have tried running it with the -U option locally, but it didn't seem to work.编辑 #1:我忘了提到是的,我尝试在本地使用 -U 选项运行它,但它似乎不起作用。

The real reason why this build fails seems to be that the repository此构建失败的真正原因似乎是存储库

https://repo.aikar.co/content/groups/aikar/ https://repo.aikar.co/content/groups/aikar/

is broken.被打破。 If you look at如果你看

https://repo.aikar.co/nexus/content/groups/aikar/com/comphenix/protocol/ProtocolLib/4.5.1-SNAPSHOT/ https://repo.aikar.co/nexus/content/groups/aikar/com/comphenix/protocol/ProtocolLib/4.5.1-SNAPSHOT/

you see a maven-metadata.xml .你会看到一个maven-metadata.xml So Maven looks at this file and sees that the repository contains the SNAPSHOT you are looking for, namely所以Maven查看了这个文件,看到存储库中包含了你要找的SNAPSHOT,即

<dependency>
    <groupId>com.comphenix.protocol</groupId>
    <artifactId>ProtocolLib</artifactId>
    <version>4.5.1-SNAPSHOT</version>
    <scope>provided</scope>
</dependency>

Unfortunately, this xml file wants to resolve the -SNAPSHOT to the version 4.5.1-20200112.025312-289 .不幸的是,这个 xml 文件想要将-SNAPSHOT解析为版本4.5.1-20200112.025312-289 This version does not exist in the directory, so Maven fails to resolve anything.目录中不存在此版本,因此 Maven 无法解析任何内容。

As a quick fix, reverse the order of the two relevant repositories.作为快速修复,颠倒两个相关存储库的顺序。

Introduction介绍

Where I work we have nexus.在我工作的地方,我们有联系。 It happens sometime that people delete libraries off their dependencies or that a mirror goes ofline and is no longer working properly.有时人们会从他们的依赖项中删除库,或者镜像脱机并且不再正常工作。

Snapshots are not Releases快照不是发布

Where I work, snapshots get cleaned/deleted quite often .在我工作的地方,快照经常被清理/删除 This means that the specific snapshot that you are trying to access has been cleaned or deleted by the system or someone.这意味着您尝试访问的特定快照已被系统或某人清除或删除。 If you can, you need to ask your team if there is a copy of the specific project.如果可以,您需要询问您的团队是否有特定项目的副本。

Then you need to either do a local build and install using: mvn clean install OR you can do a re-deployment back to nexus using: mvn clean deploy然后您需要使用以下方法进行本地构建和安装: mvn clean install或者您可以使用以下方法重新部署回 nexus: mvn clean deploy

More Information更多信息

If you happen to get the same error for a release dependency....如果您碰巧遇到发布依赖项的相同错误....

1) I usually try by be enabling or disabling some of the repositories and trying to rebuild again. 1)我通常会尝试启用或禁用某些存储库并尝试再次重建。 Have a look at your maven settings.xml configuration file.查看您的 maven settings.xml 配置文件。

2) Go to the repositories themselves and check that your dependency is actually there. 2)转到存储库本身并检查您的依赖项是否确实存在。 It happens that sometimes it has been deleted.碰巧有时它已被删除。 Do a search on your nexus or artifactory to see if the specific dependency is maybe available in a different repository.在您的联系或工件上进行搜索,以查看特定的依赖项是否可能在不同的存储库中可用。 Then add this repository into your configuration.然后将此存储库添加到您的配置中。

3) if 1 and 2 fail, it means that the specific dependency is not available in your corporate nexus or artifactory. 3) 如果 1 和 2 失败,则意味着特定依赖项在您的公司关系或人工制品中不可用。 In this case, you either have to find it online from a trusted source and will manually install it into your maven repository.在这种情况下,您要么必须从受信任的来源在线找到它,然后将其手动安装到您的 maven 存储库中。

Another option, is to add an external trusted repository to your configuration.另一种选择是将外部可信存储库添加到您的配置中。 However, be very careful with this because you could be breaking company policies and/or exposing yourself to security risks if you add an uknown repo.但是,对此要非常小心,因为如果您添加一个未知的存储库,您可能会违反公司政策和/或使自己面临安全风险。

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

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