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 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?