我正在编写一个使用 LDAP 的 Spring 应用程序。这是我的 bean 文件。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="xxxxx:xxx" />
<property name="base" value="ou=xxxxx,dc=xxxxxxx,dc=xxxxxx" />
<property name="userDn" value="uid=xxxxxxx" />
<property name="password" value="xxxxxxxx" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
<bean id="helloLdap" class="a.b.c.HelloLdap">
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>
</beans>
这是我的 bean 创建代码:
ApplicationContext fac = new ClassPathXmlApplicationContext(
"a/b/c/ldap.xml");
HelloLdap hello = (HelloLdap) fac.getBean("helloLdap");
这是我的错误信息:
线程“主”org.springframework.beans.factory.BeanCreationException 中的异常:创建类路径资源中定义的名称为“contextSource”的 bean 时出错 [xxxxxxxxxxxx]:设置属性值时出错;嵌套异常是 org.springframework.beans.PropertyBatchUpdateException;嵌套的PropertyAccessExceptions(1)是:PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'base' throw exception;嵌套异常是 java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
所以它说(最重要的是):
"Property 'base' threw exception"
我想知道这是否是因为身份验证需要 StartTLS。我没有在我的 beans 文件中的任何地方指示 StartTLS 身份验证,所以这可能是导致错误的原因。不过,我希望在创建 bean之后进行身份验证,而不是在创建过程中。
有谁知道这是否是原因(StartTLS 身份验证)?如果没有,知道我在 XML 中做错了什么吗?