如何 在Spring MVC中 使用多个Spring和MyBatis的xml配置文件(多模块配置)

来源:互联网 发布:发布淘宝优惠券的工作 编辑:程序博客网 时间:2024/05/22 10:28

多个Spring IoC bean文件:

在web.xml文件中:

http://blog.163.com/swwei_2001/blog/static/6012675720111173565597/

<context-param><param-name>contextConfigLocation</param-name><param-value>classpath*:conf/spring/applicationContext_core*.xml,classpath*:conf/spring/applicationContext_dict*.xml,classpath*:conf/spring/applicationContext_hibernate.xml,classpath*:conf/spring/applicationContext_staff*.xml,classpath*:conf/spring/applicationContext_security.xmlclasspath*:conf/spring/applicationContext_modules*.xmlclasspath*:conf/spring/applicationContext_cti*.xmlclasspath*:conf/spring/applicationContext_apm*.xml</param-value></context-param>

使用通配符:

<context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/applicationContext*.xml</param-value></context-param>



集成mybatis: 
http://www.mybatis.org/spring/zh/factorybean.html#
MyBatis的配置文件:mybatis-config.xml
MyBatis映射器文件  RoleMapper.xml
MyBatis配置文件和映射器文件可以参考《互联网轻量级框架整合开发》的第16章

<!-- 采用自动扫描方式创建mapper bean 此段代码在applicationContext.xml文件中--><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">    <property name="basePackage" value="com.ssm.chapter16" />    <property name="SqlSessionFactory" ref="SqlSessionFactory" />    <property name="annotationClass" value="org.springframework.stereotype.Repository" /></bean>

Spring MVC datasource的配置

http://blog.csdn.net/heng_ji/article/details/29216959
















 
阅读全文
0 0