Mybatis:创建bean时出错,找不到属性的类型处理程序

时间:2017-02-04 07:54:20

标签: java spring mybatis

我要映射的对象路线:

Route.java:

package com.supplyplatform.pojo;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

@Table(name = "vc_route")
public class Route extends Base {

    private Location startLocation;
    public Location getStartLocation() {
        return startLocation;
    }

    public void setStartLocation(Location startLocation) {
        this.startLocation = startLocation;
    }


    ...other fields
}

Location.java:

package com.supplyplatform.pojo;

public class Location {
    double Lat;
    double Long;

    public double getLat() {
        return Lat;
    }
    public void setLat(double lat) {
        Lat = lat;
    }
    public double getLong() {
        return Long;
    }
    public void setLong(double l) {
        Long = l;
    }

}

RouteMapper.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supplyplatform.mapper.RouteMapper">
    <select id="selectRoute" resultMap="Route">
        SELECT id,
            car_id as carid,
            driver_id as driverid,
            cost_id as costid,
            order_id as orderid,
            X(startpoint) as x, 
            Y(startpoint) as y FROM vehicle.vc_route
    </select>
    <resultMap type = "com.supplyplatform.pojo.Route" id="Route">
        <id column="id" jdbcType="INTEGER" property="id" />
        <association property="startLocation"  resultMap="Location"/> 
    </resultMap>
    <resultMap type = "com.supplyplatform.pojo.Location" id="Location">
        <result column="y" property="lat" />
        <result column="x" property="long" />
    </resultMap>
</mapper>

我正在尝试使用关联结果映射来映射Route对象。但是应用程序启动失败是因为创建bean的错误。

错误信息:

 Error creating bean with name 'routeMapper' defined in file [D:\workspace\vehicle\target\classes\com\supplyplatform\mapper\RouteMapper.class]: Invocation of init method failed;
 nested exception is java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: No typehandler found for property startLocation

0 个答案:

没有答案