摘要: 1.首先在service层中的方法前添加@Transactional @Service public class UserService { @Autowired private UserMapper userMapper; public List<User> queryAll(){ System. 阅读全文
posted @ 2019-11-16 17:05 &天涯海角& 阅读(2903) 评论(0) 推荐(0) 编辑
摘要: @Mapper和@Repository是常用的两个注解,两者都是用在dao上,两者功能差不多,容易混淆,有必要清楚其细微区别; 区别: @Repository需要在Spring中配置扫描地址,然后生成Dao层的Bean才能被注入到Service层中:如下,在启动类中配置扫描地址: @SpringBo 阅读全文
posted @ 2019-11-16 16:36 &天涯海角& 阅读(3781) 评论(0) 推荐(0) 编辑
摘要: 使用@Mapper注解 添加了@Mapper注解之后这个接口在编译时会生成相应的实现类,让其他的类进行引用 @Mapper public interface EmpMapper { public List<Emp> queryAll(); public Emp queryById(Integer e 阅读全文
posted @ 2019-11-16 16:12 &天涯海角& 阅读(1294) 评论(0) 推荐(0) 编辑