mybatis 引用对象属性映射错误 or could not be found for the javaType (xxx.model) : jdbcType (null) combination.

宽为限 紧用功 工夫到 滞塞通

使用mybatis框架时遇到的一个错误,记录一下
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 ‘productType’. It was either not specified and/or could not be found for the javaType (xxx.pojo.ProductType) : jdbcType (null) combination.

错误信息是mybatis没找到对应的jdbcTye,这里我就纳闷了,好好的对象怎么会需要映射了?以前都不用的啊???
打开该报错类的配置文件和实体类看看

productMain.xml

...
    <resultMap type="product" id="productMap">
        ...
        <association property="productType" column="product_type"
            select="xxx.mapper.ProductTypeMapper.getById" />

    resultMap>
    ...

ProductMain.java

...
    /**
     * 商品分类
     */
    private ProductType productType;

    public ProductType getProductType() {
        return productType;
    }

    public void setProductType(ProductType productType) {
        this.productType = productType;
    }
...

没发现什么毛病,productType 类型是这样的,,
看到javaType (xxx.pojo.ProductType)这个错好像发现了什么,,好端端的怎么突然要映射了呢? 莫非它不是一个属性了?,,,突然想起这个,别名!!!

sqlMapConfig.xml



<configuration>

    
    <settings>
        
        <setting name="cacheEnabled" value="true" />
        
        <setting name="useGeneratedKeys" value="true" />
        
        <setting name="defaultExecutorType" value="REUSE" />
        
        <setting name="lazyLoadingEnabled" value="true" />
        
        <setting name="defaultStatementTimeout" value="25000" />
    settings>

    
    <typeAliases>
        <typeAlias alias="user" type="xxx.pojo.ProductUser" />
        <typeAlias alias="product" type="xxx.pojo.ProductMain" />
        <typeAlias alias="productType" type="xxx.pojo.ProductType" />
        <typeAlias alias="productLabel" type="xxx.pojo.ProductLabel" />
        <typeAlias alias="productImage" type="xxx.pojo.ProductImage" />
    typeAliases>
...
alias="productType" type="xxx.pojo.ProductType" />

property="productType" column="product_type"
            select="xxx.mapper.ProductTypeMapper.getById" />

额,,重名了!这里写图片描述
改一个名字重启一下就OK啦 \(^o^)/YES!

你可能感兴趣的:(mybatis,bug标本)