标签:ldap spring-ldap xml spring java
我正在编写一个使用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");
这是我的错误信息:
Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘contextSource’ defined in class path resource [xxxxxxxxxxxx]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property ‘base’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
所以说(最重要的是)
"Property 'base' threw exception".
我想知道这是否是因为身份验证需要StartTLS.我没有在bean文件中的任何地方指示StartTLS身份验证,所以这可能是导致错误的原因.不过,我希望身份验证会在创建bean之后进行,而不是在创建过程中进行.
有谁知道这是原因(StartTLS身份验证)吗?如果不是,您对我的XML做错了什么有什么想法?
谢谢,
ktm
解决方法:
答案在错误消息中:
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
应用程序中的某些内容需要Apache Commons Lang.将其下载,然后将其添加到您的类路径中.
标签:ldap,spring-ldap,xml,spring,java 来源: https://codeday.me/bug/20191023/1914044.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。