首页 > 其他 > 详细

关于string boot中的Error creating bean with name 'userController'问题

时间:2021-04-19 14:34:58      阅读:10      评论:0      收藏:0      [点我收藏+]

新手入门 ,关于string boot中的这个问题,搞了好久,现在终于解决了

报错信息如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userController‘: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userServiceImpl‘: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userMapper‘ defined in file [D:\stringbootworkspace\cmmm\target\classes\com\xc\mjl\demo\mapper\UserMapper.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:\stringbootworkspace\cmmm\target\classes\mapper\UserMapper.xml]‘; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。

解决方案:可能有两处出错


第一处是配置文件中的

mybatis.type-aliases-package=com.xc.demo
此处必须和前面包名一致

第二处是写sql的Mapper中的,这一个最不容易找,看起来一点错都没有,但是运行就报错
<?xml version="1.0" encoding="UTF-8"?>
就是这个玩意一定要顶头写,一定一定不能空行,它就是第一行,它前面空行就会报错,

嗯,大概就这样了,希望有人看到这个错对你有用,谢谢,最后还是要说一下新手第二条切记,不明显,一不留心还容易出




关于string boot中的Error creating bean with name 'userController'问题

原文:https://www.cnblogs.com/18439593687mjl/p/14676434.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!