集成Mybatis莫名其妙报了这错,下面是我的测试代码:
@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>
乍一看没啥问题啊,报的错误看起来像是id重复之类的,网上大部分的解释也是id重复巴拉巴拉,其实,这里跟id没毛关系,是因为我在上面定义了两个重名,返回值还一样的方法
User getUser(....)
把其中一个改下名字就okay了。
😂😂😂😂
不会炒股的程序员不是好程序员,加Q一起做韭菜吧:1249943558
😂😂😂😂