MyBatis 动态代理配置

动态代理:只需要编写dao接口,不需要写具体的dao实现,接口直接调用mapper.xml中配置的sql               

1、Mapper.xml文件中的namespace与mapper接口的类路径相同。

                2、Mapper接口方法名和Mapper.xml中定义的每个statement的id相同 

                3、Mapper接口方法的输入参数类型和mapper.xml中定义的每个sql 的parameterType的类型相同

                4、Mapper接口方法的输出参数类型和mapper.xml中定义的每个sql的resultType的类型相同

                5、Dao的类名与Mapper.xml的文件名称相同

                6、配置<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> Bean

                7、包名必须将每层分开,controller,service,dao,mapper,bo层。。

猜你喜欢

转载自xinjiatao.iteye.com/blog/2370085