最近第一次用springboot,遇到一个bug
BUG内容不重要哈
就是一开始我惯性思维,复制bug第一行,然后百度
看了20min吧,没有找到合适的修改方案,甚至为什么出错我都不知道
后来看到一个帖子,他的情况跟我很相似。他选择自己把bug的提示看到最后,发现了nest(嵌套)的问题,最后顺利的解决问题
依葫芦画瓢,我也试试
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'friendLinkServiceImpl':
Unsatisfied dependency expressed through field 'friendLinkMapper';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'friendLinkMapper' defined in file [C:\Users\YIFENG\Desktop\coding\springboot\MyPage\target\classes\com\example\mypage\mapper\FriendLinkMapper.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 [C:\Users\YIFENG\Desktop\coding\springboot\MyPage\target\classes\mapper\FriendLinkMapper.xml]';
nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [C:\Users\YIFENG\Desktop\coding\springboot\MyPage\target\classes\mapper\FriendLinkMapper.xml]'.
Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.ldf.demo.pojo.FriendLink'.
Cause: java.lang.ClassNotFoundException: Cannot find class: com.ldf.demo.pojo.FriendLink
将错误一点一点分隔和分析,发现了关键的地方
其实错误很简单
改成正确的路径就可以了
这次还是惯性思维害了我
全栈老师说,要摆脱路径依赖,现在看来,确实如此