<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
beans
xmlns
=
"http://www.springframework.org/schema/beans"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context
=
"http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<
bean
class
=
"com.imooc.o2o.util.EncryptPropertyPlaceholderConfigurer"
>
<
property
name
=
"locations"
>
<
list
>
<
value
>classpath:jdbc.properties</
value
>
<
value
>classpath:redis.properties</
value
>
</
list
>
</
property
>
<
property
name
=
"fileEncoding"
value
=
"UTF-8"
/>
</
bean
>
<
bean
id
=
"abstractDataSource"
abstract
=
"true"
class
=
"com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method
=
"close"
>
<
property
name
=
"maxPoolSize"
value
=
"30"
/>
<
property
name
=
"minPoolSize"
value
=
"10"
/>
<
property
name
=
"autoCommitOnClose"
value
=
"false"
/>
<
property
name
=
"checkoutTimeout"
value
=
"10000"
/>
<
property
name
=
"acquireRetryAttempts"
value
=
"2"
/>
</
bean
>
<
bean
id
=
"master"
parent
=
"abstractDataSource"
>
<
property
name
=
"driverClass"
value
=
"${jdbc.driver}"
/>
<
property
name
=
"jdbcUrl"
value
=
"${jdbc.master.url}"
/>
<
property
name
=
"user"
value
=
"${jdbc.username}"
/>
<
property
name
=
"password"
value
=
"${jdbc.password}"
/>
</
bean
>
<
bean
id
=
"slave"
parent
=
"abstractDataSource"
>
<
property
name
=
"driverClass"
value
=
"${jdbc.driver}"
/>
<
property
name
=
"jdbcUrl"
value
=
"${jdbc.slave.url}"
/>
<
property
name
=
"user"
value
=
"${jdbc.username}"
/>
<
property
name
=
"password"
value
=
"${jdbc.password}"
/>
</
bean
>
<
bean
id
=
"dynamicDataSource"
class
=
"com.imooc.o2o.dao.split.DynamicDataSource"
>
<
property
name
=
"targetDataSources"
>
<
map
>
<
entry
value-ref
=
"master"
key
=
"master"
></
entry
>
<
entry
value-ref
=
"slave"
key
=
"slave"
></
entry
>
</
map
>
</
property
>
</
bean
>
<
bean
id
=
"dataSource"
class
=
"org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"
>
<
property
name
=
"targetDataSource"
>
<
ref
bean
=
"dynamicDataSource"
/>
</
property
>
</
bean
>
<
bean
id
=
"sqlSessionFactory"
class
=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<
property
name
=
"dataSource"
ref
=
"dataSource"
/>
<
property
name
=
"configLocation"
value
=
"classpath:mybatis-config.xml"
/>
<
property
name
=
"typeAliasesPackage"
value
=
"com.imooc.entity"
/>
<
property
name
=
"mapperLocations"
value
=
"classpath:mapper/*.xml"
/>
</
bean
>
<
bean
class
=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<
property
name
=
"sqlSessionFactoryBeanName"
value
=
"sqlSessionFactory"
/>
<
property
name
=
"basePackage"
value
=
"com.imooc.o2o.dao"
/>
</
bean
>
</
beans
>