我正在尝试使用 Spring LDAP 进行编码
<ldap-server ldif="classpath:my-ldap-clone.ldif" />
但我得到这个错误
NoClassDefFoundError: org/apache/directory/server/core/DirectoryService
我究竟做错了什么?
我正在尝试使用 Spring LDAP 进行编码
<ldap-server ldif="classpath:my-ldap-clone.ldif" />
但我得到这个错误
NoClassDefFoundError: org/apache/directory/server/core/DirectoryService
我究竟做错了什么?
使用行家:
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-all</artifactId>
<version>1.5.7</version>
</dependency>
如果您使用 Maven,这些实际上来自spring-security-ldap
.
使用apacheds-all
是一个坏主意,因为它嵌入了许多相当常见的依赖项,例如 slf4j 和 dom4j。你会很容易地遇到类加载器问题。
Instead, you should look inside the pom of the spring-security-ldap
version your are using, for the apacheds
optional dependencies, and copy them over to your pom without the <scope>
and <optional>
elements (unfortunately there is no better way to handle optional dependencies with Maven).
For instance, with spring-security-ldap
4.2.2, it would give:
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-entry</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-protocol-ldap</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-protocol-shared</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-server-jndi</artifactId>
<version>1.5.5</version>
</dependency>
(it looks like it hasn't changed since at least 3.2)
从下面的链接 http://directory.apache.org/下载 ApcheDS 或从这里获取完整的 jar 我曾经使用 Spring Security 3.0.5 和 LDAP(Spring LDAP 1.3)。那个时候我没有满足 ApacheDS 的要求。检查您的 Spring Secuirty 版本,它可能与 ApacheDS 有依赖关系。