启动springSecurity报错

报错信息:

 

 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': 
Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#5'while setting bean property 'sourceList' with key [5]; 
....................
....................
...................
Cannot resolve reference to bean 'userService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userService' available

service代码:

 

 


@Service("userService")
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UserInfo userInfo=null;
        try {
            userInfo = userDao.findByUserName(username);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //下面的User是springSecurity为我们提供的,可以用来封装我们自己从数据库中查询到的用户数据
        User user=new User(userInfo.getUsername(),userInfo.getPassword(),null);
        return user;
    }
}

 

 


spring-sercurity.xml代码:
 

谁能帮忙看一下呀,捣鼓两天了o(╥﹏╥)o

查看全部
zyszyk
z_ys
2020/12/01 14:47
  • spring
  • java-ee
  • 点赞
  • 收藏
  • 回答
    私信

2个回复