java - Maven 无法从源位置解析项目的依赖关系

标签 java maven intellij-idea

我是 Maven 的新手,所以我不确定如何解决这个问题。

我正在尝试打包我的 maven 项目 (mvn clean package) 但我收到此错误:

Failed to execute goal on project TestSDK: Could not resolve dependencies for project com.company.idea.qe:qeTestSDK:jar:1.0-SNAPSHOT: Failure to find org.slf4j:slf4j-parent:jar:1.7.21 in http://nexus-proxy/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of Company-nexus has elapsed or updates are forced -> [Help 1]

我相信这是由 Maven 使用存储库值作为下载依赖项的唯一来源造成的。我需要它来下载 WebDriverBuilder Artifact 。作为 Maven 的新手,我不知道该怎么做。

我的 pom.xml 目前看起来像这样:

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

<groupId>com.company.idea.qe</groupId>
<artifactId>qeTestSDK</artifactId>
<version>1.0-SNAPSHOT</version>

<repositories>
    <repository>
        <id>company-nexus</id>
        <name>Compnay Nexus</name>
        <url>http://nexus-proxy/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.company.tools</groupId>
        <artifactId>WebDriverBuilder</artifactId>
        <version>2.3.3</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.10</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.0</version>
    </dependency>
    <!--  Gson: Java to Json conversion -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.6.2</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-parent</artifactId>
        <version>1.7.21</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
        </plugin>
    </plugins>
</build>

最佳答案

你的依赖应该是 sl4j-api 而不是 sl4j-parent

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.21</version>
</dependency>

关于java - Maven 无法从源位置解析项目的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37259548/

相关文章:

java - 无法解析类方言

maven - docker maven 镜像的 Jenkins 管道脚本退出状态 -1

java - 对主代码和测试代码使用antlr4-maven-plugin

android - 如何缩小 Intellij Idea12 中的 Android 设计器 View ?

java - 在 eclipse 中运行 scala 的配置

java - 为什么我的光标在 ListView 中不起作用?

java - IntelliJ不断切换到UTF8(我想设置CP-1252)

java - 错误: Could not find or load main class IntelliJIdea

java - 何时应公布异常情况以及何时应进行处理的经验规则

java - SLF4J:类路径包含多个SLF4J绑定(bind);排除 slf4j