方法1:在mapper文件上加@Repository注解,这是从spring2.0新增的一个注解,用于简化 Spring 的开发,实现数据访问
方法2:在mapper文件上加@Component注解,把普通pojo实例化到spring容器中,相当于配置文件中的
Could not autowire. No beans of ‘StudentMapper‘ type found
最新推荐文章于 2024-01-27 11:20:43 发布
本文介绍了两种在Spring中整合MyBatis的方法:使用@Repository和@Component注解。@Repository通常用于数据访问层,简化Spring的开发;而@Component则可将普通POJO实例化到Spring容器。此外,还提及了Thymeleaf模板引擎的详细语法入门教程。
1万+

被折叠的 条评论
为什么被折叠?



