mybatis-spring无法自动装配mapper的问题

来源:互联网 发布:写谱子的软件 编辑:程序博客网 时间:2024/06/05 18:16

spring,mybatis3,mybatis-spring自己搭建的项目,找了很久无法自动装配mapper,检查了各种路径都还是不行,最后在http://www.mybatis.org/spring/zh/mappers.html找到

git的示例地址,发现:

<!-- scan for mappers and let them be autowired -->
<mybatis:scan base-package="org.mybatis.jpetstore.mapper" />

如果想要让容器自动装配mapper或者自定义的接口,需要制定包路径。就是这样 = =,java配置需要加上注解,@MapperScan(basePackages = {"com.spring.bean.mapper","com.spring.inter"})


配置了一个简单的spring,mybatis3.x的的项目,git地址:https://github.com/zhuojl/littleSpring

1 0
原创粉丝点击