加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java – Spring和Spring安全配置帮助,找不到bean

发布时间:2020-12-15 01:40:41 所属栏目:大数据 来源:网络整理
导读:我一直收到一条消息:“org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为userDetailsS??ervice的bean”,即使bean被定义为UserDetailsS??erviceImpl类中的服务.如: @Service(value="userDetailsService")public class UserDe

我一直收到一条消息:“org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为’userDetailsS??ervice’的bean”,即使bean被定义为UserDetailsS??erviceImpl类中的服务.如:

@Service(value="userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService{

我正在使用最新的Spring和Spring Security.

我不确定我做错了什么.我正在粘贴我的spring xml文件的配置. spring-security.xml显示它在使用组件扫描时可以从servlet-context.xml中找到bean.

谢谢

org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.filterChains': Cannot resolve reference to bean org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean org.springframework.security.authentication.ProviderManager#0' while setting bean property authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.authenticationManager': Cannot resolve reference to bean org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userDetailsService' is defined

弹簧security.xml文件


servlet的context.xml中


最佳答案
您需要在其他Spring配置文件中放置组件扫描,而不仅仅是servlet配置.

它们是不同的上下文,一个由上下文加载器侦听器加载,一个由调度程序servlet加载.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读