springboot+mybatis项目 resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]

在用eclipse运行springboot+mybatis过程中报错信息:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'raceController': Unsatisfied dependency expressed through field 'raceService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'raceServiceImp': Unsatisfied dependency expressed through field 'raceDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'IRaceDao' defined in file [D:\STSworkspace\cms\target\classes\com\example\cms\dao\IRaceDao.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.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 16; 文档根元素 "configuration" 必须匹配 DOCTYPE 根 "mapper"

解决方法:

我的目录结构是
在这里插入图片描述
是application.properties的mybatis配置出的问题

mybatis.type-aliases-package=com.example.cms.bean
mybatis.mapper-locations=classpath:com/example/cms/mapper

mybatis.config-location=classpath:mybatis-config.xml

只用加上面两条配置就好了,把location注释掉就能运行了

发布了4 篇原创文章 · 获赞 1 · 访问量 157

猜你喜欢

转载自blog.csdn.net/weixin_46255209/article/details/104331400