天天看点

Initialization of bean failed; nested exception is org.springframework.beans.factory.: 错误分析

按照之前调试成功的两个表关联,加入更多的表,今天加入一个表,就出现以下错误

Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:

Error creating bean with name 'sessionFactory' defined in file […….xml]: Invocation of init method failed;

nested exception is org.hibernate.HibernateException:

Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]

在网上查找了原因

可能原因如下:

1.真的没有写getter方法(发生几率:1%)

2.*.hmb.xml文件中的属性名和pojo不一致(*.hbm.xml和*.java没衔接好,不一致),字段属性没有正确配置,

比如,*.hmb.xml中*.java的地址要明确(明确指出引用包的完整路径);映射错误;有多个主键时,对生成的联合主键配置错误;

拼写错误(包括多空格)等(发生几率:48%)

3.方法写错/方法名写错,要按照javabean的书写规范写啊,要不然打死也找不到哪儿错了(发生几率:50%)

这里提一下:get/set是不是不允许方法名中有连续两个大写字母,例如

public String getODPType(){

       return this.oDPType;

}

public void setODPType(String  oDPType){

this.oDPType = oDPType;

这样写它就会报错,报找不到getter for oDPType的错误,但下面这样写就可以了

public String odpType;

public String getOdpType(){

       return this.odpType;

public void setOdpType(String      odpType){

this.odpType = odpType;