1.web.xml
<!-- 加载spring容器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring-config.xml</param-value>
</context-param>
2.spring-config.xml
<import resource="spring/applicationContext-dao.xml" />
3.applicationContext-dao.xml
<!-- 配置mybatisSqlSessionFactoryBean -->
<bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:com/jd/m/cms/bjshare/dao/sqlmap/*.xml"/>
<property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml"/>
</bean>
4.如果spring-config.xml和applicationContext-*.xml保存在一个文件夹下,那么mybatis配置文件*.xml就不能保存在根目录下,否则启动找不到
如果spring-config.xml和applicationContext-*.xml不保存在一个文件夹下,那么mybatis配置文件*.xml就可以保存在根目录下,系统正常启动