SSM+shiro 在realm中出现注解注入service失败
来源:互联网 发布:阿里云备案幕布剪裁 编辑:程序博客网 时间:2024/06/08 21:29
错误重现
Error creating bean with name 'shiroFilter' defined in class path resource [applicationContext.xml]:BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'securityManager' defined in class path resource [applicationContext.xml]: Cannot resolve reference to
bean 'jdbcRealm' while setting bean property 'realms' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'jdbcRealm': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field:
com.test.shiro.service.UserService com.test.shiro.realms.ShiroRealm.userService;
nested exception is java.lang.IllegalArgumentException: Can not set com.test.shiro.service.UserService
field com.test.shiro.realms.ShiroRealm.userService to com.sun.proxy.$Proxy18
反正就是一大堆、重点就是realm注入不了service这样就不能从数据库中读取到用户的信息
大概的原因 应该就是SPring在创建代理类的时候不能生成
因为我的service直接用实现的方式而不是用接口实现这样会出现代理不能扫描注入。
接下来就是改变
写一个接口
public interface UserServiceInterface {List<User> getall();User findByUsername(String username);User selectByPrimaryKey(int id);}
实现他
@Servicepublic class UserService implements UserServiceInterface{@AutowiredUserMapper userMapper;/** * 查询所有员工 * * @return */public List<User> getall() {return userMapper.selectByExample(null);}
后面省略。
然后在realm中在使用
@Repositorypublic class ShiroRealm extends AuthorizingRealm {@AutowiredUserServiceInterface userService;User user;
搞定了!!!
阅读全文
1 0
- SSM+shiro 在realm中出现注解注入service失败
- Shiro Realm @Autowired 注入失败的问题
- shiro realm 注解失败问题解决过程
- 使用Spring配置shiro时,自定义Realm中属性无法使用注解注入解决办法
- 使用Spring配置shiro时,自定义Realm中属性无法使用注解注入解决办法
- ssm和shiro整合,shiro的自定义的realm不能自动注入的问题
- (六) shiro在web中自定义Realm
- 在Action中使用@Resource注解注入失败
- DUBBO出错笔记(三)shiro 自定义realm注入失败解决办法
- 在ssm项目中引入shiro
- servlet中利用spring的注解@Autowired自动注入service失败,优雅的解决方法
- java中SSM整合shiro dubbo service层相互调用
- shiro自定义realm无法使用注解
- SpringMvc+MyBatis+Shiro整合,shiro的realm不能注入Bean
- 在Filter中注入Service
- SpingMVC启动出现注解注入失败情况之一
- spring+mybatis使用注解形式出现注入失败可能原因
- ssm项目controller层@Value注解注入Integer等类型失败解决方法
- Redis安装
- Mysql5.7 在Centos6 中安装
- 手势识别器GestureDetector
- PHP中过滤 特殊字符
- tomcat connectionpool的配置方法及验证
- SSM+shiro 在realm中出现注解注入service失败
- 文件下载代码
- AnimationTing2
- PHP使用Redis
- Android测试框架
- JAVA实战项目--文章发布系统
- 动态规划训练17 [Super Jumping! Jumping! Jumping! HDU
- CentOS6上安装和使用MariaDB
- Servlet的生命周期