2015-10-19 88 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