yaoyy09 2016-01-21 03:21 采纳率: 0%
浏览 2394

Spring3整合Mybatis3+mybatis-spring1.x查询报错

我在进行Spring(V:3.2.3.RELEASE)+mybatis(V:3.2.4)+mybatis-spring(V:1.1.1)整合。有一个ClassRoom班级类:
//班级id
private int classId;
//班级编码
private String classCode;
//班级名字
private String className;
//所属学院
private College college;
//标记
private int flag;
学院类College属性是:
private int collegeId;
private String collegeCode;
private String collegeName;
private int flag;

ClassRoomMapper.xml配置如下:





<!-- -->






查询班级信息语句如下:

select t.class_id, t.class_code,t.class_name, t.flag as 'class_flag',t2.college_code, t2.college_id, t2.college_name, t2.flag as 'college_flag' from t_class t left join t_college t2 on t.college =t2.college_code where t.class_code = #{classCode}

beans.xml中配置ClassDao如下:



在进行查询(loadByCode) 的时候报错如下:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'classRoomDao'
defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sqlSessionFactory'
while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init
method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource
[mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration.
Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalStateException:
Type handler was null on parameter mapping for property 'college'. It was either not specified and/or could not be found
for the javaType / jdbcType combination specified.

请问这是什么原因呢?还需要重新写college与数据库字段对应的关系吗?我已经在association中增加了对应字段的配置。

  • 写回答

6条回答

  • yaoyy09 2016-01-21 03:25
    关注

    刚才看配置的xml文件不显示,重新补充下。
    ClassRoomMapper.xml配置如下:





    <!-- -->







    ---------------------------------------------------------------------
    beans.xml中配置ClassDao如下:



    评论

报告相同问题?

悬赏问题

  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作