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

时间:2019-01-22 05:57:05

标签: java maven

我正在尝试创建一个使用sikulix库的程序。因此,我从https://mvnrepository.com/artifact/com.sikulix/sikulixapi/1.1.2复制粘贴了相关性。然后我运行mvn install安装库,但出现此错误
[ERROR] Failed to execute goal on project auto-fish: Could not resolve dependencies for project com.bine:auto-fish:jar:1.0: Could not find artifact com.github.vidstige:jadb:jar:-v1.0-g94ebf38-23 in central (https://repo.maven.apache.org/maven2)

做完一些研究后,我意识到我可能需要在sikulixapi存储库中添加一个存储库标签。那给了我这个错误。

[ERROR] Failed to execute goal on project auto-fish: Could not resolve dependencies for project com.bine:auto-fish:jar:1.0: Could not find artifact com.github.vidstige:jadb:jar:-v1.0-g94ebf38-23 in Sikulix Repo (https://mvnrepository.com/artifact/com.sikulix/sikulixapi)

在这一点上,我不确定应该做什么。这是我每个Maven项目的第一个。 `

http://maven.apache.org/xsd/maven-4.0.0.xsd“>     4.0.0

<groupId>com.bine</groupId>
<artifactId>auto-fish</artifactId>
<version>1.0</version>

<name>auto-fish</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>

 <repositories>
    <repository>
        <id>Sikulix Repo</id>
        <url>https://mvnrepository.com/artifact/com.sikulix/sikulixapi</url>
    </repository>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.sikulix/sikulixapi -->
    <dependency>
        <groupId>com.sikulix</groupId>
        <artifactId>sikulixapi</artifactId>
        <version>1.1.2</version>
    </dependency>

</dependencies>

<build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
        <plugins>
            <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>
            <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.7.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

` 代码已拆分,但请注意,它们都在我的maven项目的pom文件中。另外前五行由于某种原因没有出现,但我觉得它们并不重要。而我正在为此使用Vs代码。

如果您想知道这样做的目的是创建可以为我玩一些愚蠢的钓鱼游戏的东西,但这更多地是一种测试,以了解我是否可以将其拉开,而不是我真正需要的东西。

2 个答案:

答案 0 :(得分:1)

如果您查看mvnrepository.com中的vidstige工件,您会看到它列出了“ Mulesoft”作为包含它的唯一存储库。在该链接之后,显示https://repository.mulesoft.org/nexus/content/repositories/public/作为您应该添加的可选存储库URL,而不是您添加的mvnrepository URL,它只是指向mvnrepository搜索引擎结果的链接。

因此,简而言之,这应该可以工作:

<repository>
    <id>Mulesoft Repo</id>
    <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
</repository>

请注意,我不熟悉此存储库,因此,如果它需要任何形式的身份验证或许可,则需要按照该存储库所有者的说明进行操作。

答案 1 :(得分:0)

或者,您可以使用排除项跳过依赖项下载。 由于我不知道您的源代码。我只是建议这种解决方案

<dependency>
  <exclusions>
  <exclusion>
  <groupId>com.github.vidstige</groupId>
  <artifactId>jadb</artifactId>
  </exclusion>
 </exclusions>
</dependency>

LaunchPad找到的解决方案