java – Spring为undefined bean抛出异常

前端之家收集整理的这篇文章主要介绍了java – Spring为undefined bean抛出异常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在关注this tutorial以使用Spring Security.我想使用Hibernate进行数据库查询.我配置了代码,但抛出了异常.

我在spring-security.xml和my-servlet.xml中定义了bean,但仍然没有结果.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myMemberDetailsService' is defined
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.getBeanDefinition(DefaultListablebeanfactory.java:570)
    at org.springframework.beans.factory.support.Abstractbeanfactory.getMergedLocalBeanDefinition(Abstractbeanfactory.java:1114)
    at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:279)
    at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:320)
    ... 93 more

MemberRepository

public class MemberRepositoryImpl implements MemberRepository {

    SessionFactory sessionFactory;

    @SuppressWarnings("unchecked")
    @Override
    public Member findByUserName(String username) {

        List

MyMemberDetailsS​​ervice

public class MyMemberDetailsService implements UserDetailsService {

    private MemberRepository memberRep;

    @Override
    public UserDetails loadUserByUsername(final String username)
            throws UsernameNotFoundException {

        Member member = memberRep.findByUserName(username);
        HashSet

我-servlet.xml中

MysqL.jdbc.Driver" />
        MysqL://localhost:8889/myProject" />
        factorybean"
        depends-on="dataSource">
        MysqLDialectsql">truesql_comments">truesql">true

弹簧security.xml文件

403" />
        logout logout-success-url="/login?logout" />
         原文链接:https://www.f2er.com/spring/431574.html

猜你在找的Spring相关文章