使用spring整合mybatis时映射文件的导入方法
2013-04-29 19:03
537 查看
使用spring整合mybatis时映射文件的导入方法主要有两种:
方法1:例如在sqlMapConfig.xml文件中配置:
<mappers>
<mapper resource="com/njupt/pojo/User.xml" />
<mapper resource="com/njupt/pojo/Person.xml" />
<mapper resource="com/njupt/pojo/Order.xml" />
</mappers>
方法2:也可以直接在spring的配置文件中配置:如下所示:
<bean id="sf" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:sqlMapConfig.xml"/>
<property name="mapperLocations">
<value>classpath:com/njupt/pojo/User.xml</value>
</property>
</bean>
方法1:例如在sqlMapConfig.xml文件中配置:
<mappers>
<mapper resource="com/njupt/pojo/User.xml" />
<mapper resource="com/njupt/pojo/Person.xml" />
<mapper resource="com/njupt/pojo/Order.xml" />
</mappers>
方法2:也可以直接在spring的配置文件中配置:如下所示:
<bean id="sf" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:sqlMapConfig.xml"/>
<property name="mapperLocations">
<value>classpath:com/njupt/pojo/User.xml</value>
</property>
</bean>
相关文章推荐
- spring+mybatis整合,不需要配置映射文件,多路径配置
- SSM实战——秒杀系统之DAO层实体定义、接口设计、mybatis映射文件编写、整合Spring与Mybatis
- MyBatis Spring整合配置映射接口类与映射xml文件
- Spring Boot 整合mybatis 使用多数据源的实现方法
- 如何在mybatis映射文件里面使用java方法
- MyBatis Spring整合配置映射接口类与映射xml文件
- maven下 spring+springmvc+mybatis整合,映射文件加载异常
- 浅谈spring+springMVC+mybatis框架整合(配置文件的使用)
- mybatis3 spring整合的好方案及其使用注解操作的方法如下
- 使用Spring 来配置 hibernate 映射文件的 两种方法
- Spring、MyBatis的整合数据映射器类(UserMapper->iocContext.xml)配置文件详解
- Intellij IDEA使用(十二)—— 使用Intellij IDEA导入Eclipse创建的Spring+SpringMVC+Mybatis(SSM)整合项目并修改相关配置
- Spring集成Mybatis配置映射文件方法详解
- Spring+MyBatis整合使用MapperFactoryBean注入映射器(简化配置)
- mybatis 高级映射和spring整合之逆向工程(7)
- mybatis和spring整合的一系列问题(没使用maven)
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- 使用MyBatis-Generator自动生成映射文件
- Spring4-Thymeleaf-MyBatis整合Context文件
- Spring、Spring MVC、Mybatis整合配置文件详解