导入mybatis jar包
右键pom.xml
定义接口
@Mapper
public interface GoodsDao {
/**
* 基于商品id删除商品
* @param id 商品id
* @return 删除行数
* 数据层方法对象的sql映射
*/
@Delete("delete from tb_goods where id=#{id}")
int deleteById(Integer id);
}
测试
@SpringBootTest
public class TestGoods {
@Autowired
private GoodsDao gd;
@Test
void TestGoods() {
int i =gd.deleteById(10);
System.out.println(i);
}
}
原文:https://www.cnblogs.com/syrgdm/p/13414448.html