无效的属性' defaultCountLimit' bean类[org.springframework.ldap.core.LdapTemplate]

时间:2015-10-19 12:27:29

标签: java spring spring-ldap

尝试在Spring上配置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" />

我已经检查了配置,当我不通过spring上下文工作时它工作正常 -

    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 个答案:

答案 0 :(得分:1)

这可能是由于依赖版本不匹配造成的。确保您只参考正确的maven文物。对于基本情况,您只需要spring-ldap-core:

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

您列出的spring-ldap依赖项是遗留的,不应包括在内。