at dxm.com.web.UsersCRUD.main(UsersCRUD.java:23)
mapper中将接口类配置, 同时将xml的命名空间也也映射到了接口,注释掉接口类的配置。
经过多番测试 正确的配置方式有一些两种
第一种 配置 中加载 xml,xml文件的namespace对应 接口完全限定名。
第二种 配置接口 接口中包含注解的sql语句
--------------------------------------------------------------------------------------------------------------
第一种包含内容
userMapper.xml 文件内容:
insert into user(userid,username,others) values(#{userid},#{username},#{others})
update user
set username=#{username},others=#{others}
where userid=#{userid}
delete from user where userid=#{userid}
insert into user(userid,username,others) values
(#{item.userid},#{item.username},#{item.others})
接口内容
public interface UserMapperDao {
public int add(User user);
public int delete(int id);
public int update(User user);
public User getUser(int id);
public int addOne(User user);
public int deleteOne(int id);
public int updateOne(User user);
public User getUserOne(int id);
public List
public int insertBatch(List
}
第二种接口 定义内容:
public interface UserMapper {
@Insert("insert into user(userid,username,others) values(#{userid},#{username},#{others})")
public int add(User user);
@Delete(" delete from user where userid=#{id}")
public int delete(int id);
@Update("update user set username=#{username},others=#{others} where userid=#{userid}")
public int update(User user);
@Select("select *from user where userid=#{id}")
public User getUser(int id);
@Insert("insert into user(userid,username,others) values(#{userid},#{username},#{others})")
public int addOne(User user);
@Delete(" delete from user where userid=#{id}")
public int deleteOne(int id);
@Update("update user set username=#{username},others=#{others} where userid=#{userid}")
public int updateOne(User user);
@Select("select *from user where userid=#{id}")
public User getUserOne(int id);
@Select("select *from user")
public List
}