springboot:UnsatisfiedDependencyException: Error creating bean with name “xxxcontroller“

2020-10-29 14:55:06.429 ERROR 13344 --- [main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'modelController' defined in file [F:\Idea Project\Springboot\mini\target\classes\xyz\zzdyy\controller\ModelController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'modelMapper' defined in file [F:\Idea Project\Springboot\mini\target\classes\xyz\zzdyy\mapper\ModelMapper.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 [F:\Idea Project\Springboot\mini\target\classes\mybatis\mapper\ModelMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [F:\Idea Project\Springboot\mini\target\classes\mybatis\mapper\ModelMapper.xml]'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'Model'.  Cause: java.lang.ClassNotFoundException: Cannot find class: Model

刚开始我想着是Dao层、Service层、Controller层漏了某个注解,找了很久,也在百度找了很多解决方案但是都并没有用,我开始怀疑是我的springboot版本问题 用的是2.3.3。然后我又开了个项目 用了最新的稳定版本2.3.4 发现还是无济于事。版本的坑排除了,接下来还是继续找问题。

起初发现有些码友解决的方案是在Application里面加一个ComponentScan


马上报红,把我整懵了
我开始意识到我和其他人的问题不在一个层面上,或许我错误的原因更高级。。直到我扫文件,突然脑子一闪,会不会是配置文件的问题。我马上打开我的yaml配置文件,要不就是我的spring存在着参数配置问题,要不就是mybatis的问题,带着这个方向我去找答案,突然被我发现…(截图非原错误代码,只是我为了大家更方便看)

我直接把上一个项目的yaml文件拿过来直接用了!!心想着配置的东西都一样,无非就是配置个mysql的地址驱动什么的,都可以直接复用,就懒得检查了!!!

当然,这种低级错误,大多数人都不会犯…我也就当作记录一下自己的愚蠢事迹

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值