java - Maven 无法解决依赖关系

标签 java maven dependencies

我们有一个 Maven 项目无法解析依赖项:

[ERROR] Failed to execute goal on project lima-broker-mule: Could not resolve dependencies for project broker:lima-broker-mule:mule:2.0: The following artifacts could not be resolved: com.sun.xml.messaging.saaj:saaj-impl:jar:1.3-osgi, mx4j:mx4j-jmx:jar:2.1.1-osgi, mx4j:mx4j-impl:jar:2.1.1-osgi, mx4j:mx4j-tools:jar:2.1.1-osgi, mx4j:mx4j-remote:jar:2.1.1-osgi, com.yourkit:yjp-controller-api-redist:jar:9.0.8, org.springmodules:spring-modules-cache:jar:0.9, org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1-osgi, commons-codec:commons-codec:jar:1.3-osgi, commons-httpclient:commons-httpclient:jar:3.1-osgi, dom4j:dom4j:jar:1.6.1-osgi, commons-jxpath:commons-jxpath:jar:1.3-osgi, com.thoughtworks.xstream:xstream:jar:1.2.2-osgi, xpp3:xpp3_min:jar:1.1.3.4.O-osgi, jaxen:jaxen:jar:1.1.1-osgi, net.java.dev.stax-utils:stax-utils:jar:20080702-osgi, net.sf.saxon:saxon-dom:jar:8.9.0.4-osgi, net.sf.saxon:saxon-xqj:jar:8.9.0.4, net.sf.saxon:saxon:jar:8.9.0.4-osgi, javax.activation:activation:jar:1.1-osgi, org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec:jar:1.1-osgi: Could not find artifact com.sun.xml.messaging.saaj:saaj-impl:jar:1.3-osgi in all.repos (http://our.local/artifactory/all)

问题是我们没有在 pom.xml 中直接引用这些依赖项:

<dependencies>

  <!-- Project -->
  <dependency>
      <groupId>de.lineg.lima.broker</groupId>
      <artifactId>lima-broker-service</artifactId>
      <version>${project.version}</version>
      <scope>compile</scope>
  </dependency>

  <dependency>
      <groupId>net.sourceforge.jtds</groupId>
      <artifactId>jtds</artifactId>
      <version>1.2.4</version>
      <scope>compile</scope>
  </dependency>

  <!-- Transports used by the Mule config -->
  <dependency>
      <groupId>org.mule.modules</groupId>
      <artifactId>mule-module-cxf</artifactId>
      <version>3.2.0</version>
      <scope>provided</scope>
  </dependency>
  <dependency>
      <groupId>org.mule.transports</groupId>
      <artifactId>mule-transport-email</artifactId>
      <version>3.2.0</version>
      <scope>provided</scope>
  </dependency>
  <dependency>
      <groupId>org.mule.transports</groupId>
      <artifactId>mule-transport-vm</artifactId>
      <version>3.2.0</version>
      <scope>provided</scope>
  </dependency>
  <dependency>
      <groupId>org.mule.transports</groupId>
      <artifactId>mule-transport-jetty</artifactId>
      <version>3.2.0</version>
      <exclusions>
          <exclusion>
              <groupId>org.mortbay.jetty</groupId>
              <artifactId>servlet-api</artifactId>
          </exclusion>
          <exclusion>
              <groupId>org.apache.tomcat</groupId>
              <artifactId>jsp-api</artifactId>
          </exclusion>
          <exclusion>
              <groupId>org.apache.tomcat</groupId>
              <artifactId>jasper</artifactId>
          </exclusion>
          <exclusion>
              <groupId>org.apache.tomcat</groupId>
              <artifactId>jasper-el</artifactId>
          </exclusion>
      </exclusions>
  </dependency>

  <!-- Unit tests -->
  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
  </dependency>
  <dependency>
      <groupId>org.mule.tests</groupId>
      <artifactId>mule-tests-functional</artifactId>
      <version>3.2.0</version>
      <scope>test</scope>
  </dependency>
  <dependency>
      <groupId>org.mule.modules</groupId>
      <artifactId>mule-module-client</artifactId>
      <version>3.2.0</version>
      <scope>test</scope>
  </dependency>
  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>3.0.5.RELEASE</version>
      <scope>test</scope>
  </dependency>
  <dependency>
      <artifactId>ojdbc6</artifactId>
      <groupId>com.oracle</groupId>
      <scope>test</scope>
      <optional>true</optional>
  </dependency>
  <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <scope>test</scope>
  </dependency>
  <dependency>
      <groupId>org.easytesting</groupId>
      <artifactId>fest-assert</artifactId>
      <scope>test</scope>
  </dependency>
  <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <scope>test</scope>
  </dependency>

  <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <version>1.0.20061217</version>
      <scope>test</scope>
      <optional>true</optional>
  </dependency>
</dependencies>

我真的不知道如何解决这个问题。依赖项不在我们在artifactory 中的存储库中,而且我在任何在线存储库中都找不到其中的一些依赖项。我不知道如何找出如何引用这些依赖项,并且来自 Maven 的依赖项插件不能真正帮助我,因为在依赖项插件的任何输出出现之前构建失败。

知道如何解决这个问题吗?有什么办法可以追踪这个问题的根源吗?

最佳答案

Could not find artifact com.sun.xml.messaging.saaj:saaj-impl:jar:1.3-osgi in all.repos (http://our.local/artifactory/all)

com.sun.xml.messaging.saaj:saaj-impl:jar:1.3-osgi artifact 是一个 sun 库,有些在公共(public)远程存储库中不可用(出于合法性问题),此外它是一个 osgi 版本(这也不常见)。
因此,您在公共(public) Maven 存储库中找不到它也就不足为奇了。

com.sun.xml.messaging.saaj:saaj-impl:jar:1.3-osgi依赖项在您的 pom 中不可见,因为它可能是传递依赖项,即由您包含的依赖项拉取的依赖项。
由于您没有显示构建的完整错误消息,因此我们无法确切地说出哪个依赖项拉动了它。

要解决您的问题,您可以确定哪个依赖项会拉取此缺失的依赖项,并在包含此缺失依赖项的依赖项的问题跟踪中查找并添加该问题(如果不存在)。也许有一个解决方法,例如添加可以提供依赖项的 Maven 存储库。

无论如何,您可以尝试在网络上找到可靠来源的库,下载它并将其安装在您的 Artifact 中,使用 deploy:deploy-file部署 Maven 插件的目标。

看看这个例子: https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html

关于java - Maven 无法解决依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44130713/

相关文章:

Android Studio - 无法解决依赖关系

java - 将类及其所有依赖项移至另一个项目

java - 在中央找不到 Artifact org.jboss.seam :jboss-seam:jar:2. 3.5.Final-redhat-1

java - 在 Java 中查找 href 链接和 URL 的内容

java - 如何在 SWT 中添加文本大小

maven - 如何使用 mvnw 命令进行第一个项目设置

java - 如何使用 Google Cloud Shell 构建和部署我的代码

java - m2e maven eclipse 插件未配置构建路径

ruby - 找出 gem 的二进制依赖项

java - JWrapper JWSystem.forkVirtualApp()