< beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:context = "http://www.springframework.org/schema/context"
xmlns:p = "http://www.springframework.org/schema/p"
xmlns:mvc = "http://www.springframework.org/schema/mvc"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
< context:component-scan base-package = "com" />
< mvc:annotation-driven />
< context:property-placeholder location = "classpath:db.properties" />
< bean id = "ds1" class = "org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName = "${mysql.driver}"
p:url = "${mysql.url}"
p:username = "${mysql.username}"
p:password = "${mysql.password}" />
< bean id = "ds2" class = "org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName = "${mysql2.driver}"
p:url = "${mysql2.url}"
p:username = "${mysql2.username}"
p:password = "${mysql2.password}" />
< bean id = "multipleDataSource" class = "com.etoak.util.MultipleDataSource" >
< property name = "defaultTargetDataSource" ref = "ds1" />
< property name = "targetDataSources" >
< map >
< entry key = "ds1" value-ref = "ds1" />
< entry key = "ds2" value-ref = "ds2" />
</ map >
</ property >
</ bean >
< bean id = "sqlSessionFactory1" class = "org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref = "multipleDataSource"
p:mapperLocations = "classpath:com/etoak/dao/*-mapper.xml" />
< bean class = "org.mybatis.spring.mapper.MapperScannerConfigurer" >
< property name = "basePackage" value = "com.etoak.dao" />
< property name = "markerInterface" value = "com.etoak.dao.BaseDao" />
</ bean >
</ beans >
|