我把spring库升级到了3.2.9,以进行java 8升级。我得到以下错误。任何指针将不胜感激
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'acsManagerImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private net.taxstream.acs.repository.LdapDAO net.taxstream.acs.service.AcsManagerImpl.ldapDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapDao' defined in ServletContext resource [/WEB-INF/caa-servlet.xml]: Cannot resolve reference to bean 'ldapTemplate' while setting bean property 'ldapTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapTemplate' defined in ServletContext resource [/WEB-INF/caa-servlet.xml]: Cannot resolve reference to bean 'contextSource' while setting bean property 'contextSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'contextSource' is defined
这是AcsManagerImpl:
@Service
public class AcsManagerImpl implements AcsManager {
@Autowired
private AcsRepository acsRepository;
@Autowired
private LdapDAO ldapDao;
/**
* @param acsRepository the acsRepository to set
*/
public void setAcsRepository(AcsRepository acsRepository) {
this.acsRepository = acsRepository;
}
public <T extends Serializable> Page<T> getComponent(Class<T> type, Pageable pageable) {
return acsRepository.getComponent(type, pageable);
}
}
这就是LDAPDAO:
public interface LdapDAO<E> {
List<E> getUserInfo(final String uid);
List<E> searchUsers(final String uid);
void setFilter(final String filter);
void setAttributes(final String[] attrs);
}
这是CAAservlet代码片段
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"
p:contextSource-ref="contextSource"
p:ignorePartialResultException="true"
/>
<bean id="ldapDao" class="net.acs.repository.LdapDaoImpl">
<property name="ldapTemplate" ref="ldapTemplate" />
<property name="filter" value="(uid=@)" />
<property name="attributes">
<list>
<value>cn</value>
<value>mail</value>
<value>uid</value>
<value>givenname</value>
<value>sn</value>
</list>
</property>
</bean>
上下文源在application context.xml中定义:
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://C5QSQ13:10389/" />
<property name="base" value="ou=people,o=sevenSeas" />
<property name="anonymousReadOnly" value="true" />
</bean>
1条答案
按热度按时间sauutmhj1#
看起来你缺少一个contextSource。它在完整的错误信息中。
示例:
更多信息-> https://docs.spring.io/spring-ldap/docs/current/reference/#code-contextsource-code-configuration