项目的controller service注入失败

来源:6-2 登录功能开发

ranice

2018-04-23

部分报错如下:

四月 23, 2018 9:47:35 下午 org.springframework.web.context.ContextLoader initWebApplicationContext

严重: Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mmall.service.IUserService com.mmall.controller.portal.UserController.iUserService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'iUserService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mmall.dao.UserMapper com.mmall.service.impl.UserServiceImpl.userMapper; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userMapper' defined in file [C:\Software\tomcat\apache-tomcat-7.0.75\webapps\ROOT\WEB-INF\classes\com\mmall\dao\UserMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext-datasource.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Software\tomcat\apache-tomcat-7.0.75\webapps\ROOT\WEB-INF\classes\mappers\UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext-datasource.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Software\tomcat\apache-tomcat-7.0.75\webapps\ROOT\WEB-INF\classes\mappers\UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap


spring的配置文件是拉的老师的配置文件 ,controller和service里也加了@controller和@service注解,但是扫描失败

以前也遇到过这个问题,原因是jkd1.8和spring3不兼容 会报这个扫描不到的情况

但是这个是jdk1.7和spring4,和老师的一样,不知道为什么会报这个做,我的环境也和老师一样,只是操作系统是window10

老师在这个问答https://coding.imooc.com/learn/questiondetail/42709.html

里面讲的我没明白,希望老师能给我个解决问题的方向和思路

写回答

2回答

ranice

提问者

2018-04-25

问题解决了 

UserMapper.xml的 <select id="selectLogin" resultMap="BaseResultMap" parameterType="map"> 

应该写resultMap="BaseResultMap"  写成了resultType="BaseResultMap" 

1
1
Geely
赞同学!!
2018-04-29
共1条回复

polo哦

2018-04-23

扫描失败只能是你的配置文件配置错误了,看看你的配置文件吧~

0
0

从0开始 独立完成企业级Java电商网站服务端开发

前后端分离,数据库接口设计,架构设计,功能开发,上线运维

9476 学习 · 8804 问题

查看课程