专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 软件架构设计

mybatis-spring 调整时的映射器映射原理

发布时间:2011-06-20 02:11:00 文章来源:www.iduyao.cn 采编人员:星星草
mybatis-spring 整合时的映射器映射原理
---------1,mybatis 配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC
"-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--
<typeAliases> <typeAlias alias="xxx"
type="com.xxx.xxx.x" /> </typeAliases>
-->
<!-- mapper  如果映射xml文件 和接口在相同路径下,MapperFactoryBean 会自动解析,
  不需要在mybatis 的配置文件中去指定映射文件,
  路径不同时,需要在配置文件中指定加载xml 映射文件。
-->
<mappers>
         <!--如路径相同,此处可以不指定xml映射文件 -->
<mapper resource="com/xxxx/mapper/xxxMapper.xml" />

</mappers>
</configuration>


------------2,spring 配置 映射器注入
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- mapper  如果映射xml文件 和接口在相同路径下,MapperFactoryBean 会自动解析,
  不需要在mybatis 的配置文件中去指定映射文件,路径不同时,需要在配置文件中指定加载xml 映射文件。
-->
<bean id="xxxMapper" class="org.mybatis.spring.MapperFactoryBean">
<property name="mapperInterface"
value="com.xxx.mapper.xxxxMapper" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>

</beans>
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: