0
点赞
收藏
分享

微信扫一扫

使用spring整合mybatis时映射文件的导入方法


使用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>

举报

相关推荐

0 条评论