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

  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);

你可能感兴趣的:(MyBatis)