2015-10-19 95 views
0

即时得到以下异常尝试配置上春季LDAPTemplate -无效属性 'defaultCountLimit'[org.springframework.ldap.core.LdapTemplate]

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapTemplate': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'defaultCountLimit' of bean class [org.springframework.ldap.core.LdapTemplate]: Bean property 'defaultCountLimit' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 

我的配置是 -

<ldap:context-source 
     id="contextSource" 
     url="myurl" 
     base="mybase" 
     username="myuser" 
     password="mypassword" 
     referral="follow" 
/> 

<ldap:ldap-template id="ldapTemplate" context-source-ref="contextSource" /> 

伊夫检查的配置,它工作正常,当我不通过弹簧环境中工作 -

LdapContextSource contextSource = new LdapContextSource(); 
    contextSource.setUrl("myurl"); 
    contextSource.setBase("mybase"); 
    contextSource.setUserDn("myuser"); 
    contextSource.setPassword("mypassword"); 
    contextSource.setReferral("follow"); 
    contextSource.afterPropertiesSet(); 

    LdapTemplate ldapTemplate = new LdapTemplate(contextSource); 
    ldapTemplate.afterPropertiesSet(); 

我看不到countlimit被设置为导致此问题的位置。我也尝试通过ldap-template设置最大值。

版本 -

<dependency> 
    <groupId>org.springframework.ldap</groupId> 
    <artifactId>spring-ldap-core</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.ldap</groupId> 
    <artifactId>spring-ldap</artifactId> 
    <version>1.3.1.RELEASE</version> 
    <classifier>all</classifier> 
</dependency> 

回答

1

这可能是由于依赖版本不匹配。确保你只提到正确的maven文物。对于基本的情况下,所有你需要的是弹簧LDAP的核心:

<dependency> 
    <groupId>org.springframework.ldap</groupId> 
    <artifactId>spring-ldap-core</artifactId> 
    <version>2.0.4.RELEASE</version> 
</dependency> 

你列出的spring-ldap依赖是传统的,不应该被包括在内。

+0

是的 - 有一个旧的ldap lib被我忽略的项目的另一部分导入 - 谢谢 – farrellmr

相关问题