错误集合
Mybaits:
1.Mybaits 中出现
Cause:org.apache.ibatis.reflection.ReflectionException:Error,instantiating,class Mybaits.haha.Teacher with invalid types () or values (). Cause: java.lang.NoSuchMethodException: Mybaits.haha.Teacher.<init>()
解决方法 : 是因为实体类中无无参构造函数
如: 建立SQL查询结果字段与实体属性的映射关系信息
示例1:通过setter构造领域模型
/**
* 必须提供一个无参数的构造函数
*/
2.用Mybaits 中查询,则生成的List结果会有问题 List查询的都是同一个类
例如:可见返回的结果中有 三个 一模一样的 Goods(id=1,且包含5个GoodsImg), 而我们期待的结果应该是 List{ Goods(id=1), Goods(id=2), Goods(id=3) }
解决方法 : resultMap 的 column=... 定义不能一样:
相同错误链接 :http://www.cnblogs.com/zemliu/archive/2013/08/16/3263053.html
3.没有在conf.xml中注册
Mapped Statements collection does not contain value for Mybaits.haha.ClassesMapper3.getUser
4.测试框架
在使用所有注释前必须使用@RunWith(SpringJUnit4ClassRunner.class),让测试运行于Spring测试环境
5.一直困扰我两天的问题居然是因为@Autowired 是无法注入的static类型的数据
静态方法是属于类(class)的,普通方法才是属于实体对象(也就是New出来的对象)的,spring注入是在容器中实例化对象,所以不能使用静态方法
问题连接:http://blog.csdn.net/z69183787/article/details/38402007