集成Mybatis莫名其妙報(bào)了這錯(cuò)辈挂,下面是我的測試代碼:
@Select("select * from user where username = #{username}")
@Results({
@Result(property = "username", column = "user_name"),
@Result(property = "password", column = "password")
})
User getUser(String username);
@Select("select * from user where id = #{id}")
@ResultMap("BaseResultMap")
User getUser(int id);
<?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.techsun.springheart.mapper.UserMapper">
<resultMap id="BaseResultMap" type="com.techsun.springheart.model.User">
<id column="id" jdbcType="BIGINT" property="id"></id>
<result column="username" jdbcType="VARCHAR" property="username"/>
<result column="password" jdbcType="VARCHAR" property="password"/>
</resultMap>
......
</mapper>
乍一看沒啥問題啊,報(bào)的錯(cuò)誤看起來像是id重復(fù)之類的杉允,網(wǎng)上大部分的解釋也是id重復(fù)巴拉巴拉邑贴,其實(shí),這里跟id沒毛關(guān)系叔磷,是因?yàn)槲以谏厦娑x了兩個(gè)重名拢驾,返回值還一樣的方法
User getUser(....)
把其中一個(gè)改下名字就okay了。
????????
不會(huì)炒股的程序員不是好程序員世澜,加Q一起做韭菜吧:1249943558
????????