Error creating bean with name ‘dataSourceInitializerPostProcessor‘:Unsatisfied dependency expressed

让我度娘了一天的问题

先看一下问题,

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-10-26 08:46:25.815 ERROR 10616 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceInitializerPostProcessor': Unsatisfied dependency expressed through field 'beanFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shiroFilter' defined in class path resource [com/wanghaixin/config/ShiroConfig.class]: Unsatisfied dependency expressed through method 'shiroFilterFactoryBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityManager' defined in class path resource [com/wanghaixin/config/ShiroConfig.class]: Unsatisfied dependency expressed through method 'securityManager' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRealm': Unsatisfied dependency expressed through field 'sysUserService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysUserServiceImpl': Unsatisfied dependency expressed through field 'sysUserMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysUserMapper' defined in file [D:\develop\project\mycar\mycar-service\target\classes\com\wanghaixin\dao\SysUserMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\develop\project\mycar\mycar-service\target\classes\mapper\SysMenuMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.wanghaixin.dao.SysMenuMapper.findPermsByUserId

百度有说 :jar包版本不对 ,有说是shiro整合spring boot中Shiro的自定义Realm里,需要调用dao查询用户名密码。 不可以使用自动注入。。。 都没有解决,最后是。。
解决方法:
其实是xml文件中有两个相同id引起的。删掉一个即可

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
引用\[1\]中提到了一个错误创建bean的异常,该异常是由于在helloController中的userService字段上存在依赖注入失败的问题。具体原因是找不到符合自动装配条件的com.cloud.xp.manager.service.UserService bean。\[1\] 引用\[2\]中提供了一个applicationContext-datasource.xml的配置文件,其中配置了数据源的相关信息,包括驱动类名、用户名、密码和URL等。\[2\] 引用\[3\]中指出了可能的问题是userService对象不存在,导致注入失败,并抛出了错误创建bean的异常。建议检查UserService接口的实现类是否添加了@Service注解,以确保该实现类被正确地添加到容器中。\[3\] 综上所述,错误创建bean的异常是由于依赖注入失败导致的。可能的原因是userService对象不存在或未正确添加到容器中。建议检查UserService接口的实现类是否添加了@Service注解,并确保配置文件中的数据源信息正确无误。 #### 引用[.reference_title] - *1* *3* [解决异常Error creating bean with name ‘xxxxxController‘: Unsatisfied dependency expressed through ...](https://blog.csdn.net/qq_38701478/article/details/88808628)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Error creating bean with name ‘userService‘: Unsatisfied dependency expressed through field](https://blog.csdn.net/m0_52288433/article/details/127948405)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑白极客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值