新手入门 ,关于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