3

如何使用 maven 修复缺少的工件错误com.sun.jndi.ldap?由于奇怪的二进制许可,我还尝试添加 java 存储库。这是我的 pom.xml:

<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>ActiveDirectory</groupId>
  <artifactId>my.activedirectory</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>my.activedirectory</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <repositories>
    <repository>
      <id>java.net</id>
      <url>http://download.java.net/maven/2/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>java.net</id>
      <url>http://download.java.net/maven/2/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.java.dev.swing-layout</groupId>
      <artifactId>swing-layout</artifactId>
      <version>1.0.2</version>
    </dependency>
    <dependency>
      <groupId>com.sun.jndi</groupId>
      <artifactId>ldap</artifactId>
      <version>1.2.4</version>
    </dependency>
  </dependencies>
</project>

有人可以帮我解决这个问题吗?

4

2 回答 2

3

我在使用 Maven 查找 Jndi jar 时遇到了类似的情况。Maven Central repo 不再有这个 jar。

You can download these jars from Oracle Archive @http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-plat-419418.html

and then install it into your local repository. This will solve the problem.

mvn install:install-file -DgroupId=javax.naming -DartifactId=jndi -Dversion=1.2.1 -Dpackaging=jar -Dfile=jndi-1_2_1.jar
于 2014-10-02T19:52:36.220 回答
2

如果在您指向的存储库中找不到您要查找的 jar,则会发生缺少工件异常。恐怕您所指的这个 jar 或其最新版本在http://download.java.net/maven/2存储库中不可用。

尝试 jBoss 存储库或 mavens 中央存储库

<repository>
  <id>jboss-maven2</id>
  <name>JBoss Repository</name>
  <url>http://repository.jboss.com/maven2</url>
</repository>

或者

<repository>
  <snapshots>
    <enabled>false</enabled>
  </snapshots>
  <id>central</id>
  <name>Maven Repository Switchboard</name>
  <url>http://repo1.maven.org/maven2</url>
</repository>
于 2012-06-23T17:51:20.017 回答