gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 11:02:42 24 4
gpt4 key购买 nike

尝试在 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();

我看不到在哪里设置了导致此问题的计数限制。我还尝试通过 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>

最佳答案

这可能是由于依赖项版本不匹配造成的。确保您仅引用正确的 Maven 工件。对于基本情况,您只需要 spring-ldap-core:

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

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

关于java - bean 类 [org.springframework.ldap.core.LdapTemplate] 的属性 'defaultCountLimit' 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33214383/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com