MyBatis: $的用法(字符串直接替换)

高子歌

关注

阅读 145

2022-07-27


  1. Mapper

@Select("select * from book where id=${id}")
Book selectBook(@Param("id") int id);

@Select("select * from book where bookName=${yyy}")
Book selectBook2(@Param("yyy") String yyy);

2.调用

Book book=xingmingMapper.selectBook(1);
System.out.println(book);

Book book2=xingmingMapper.selectBook2("'cppp'");
System.out.println(book2);


精彩评论(0)

0 0 举报