6 Star 8 Fork 4

copy/JavaO2O

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
spring-dao.xml 4.37 KB
一键复制 编辑 原始数据 按行查看 历史
hacker 提交于 2018-02-02 11:10 +08:00 . flush
<?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">
<!-- 1 配置整合mybatis过程 -->
<!-- 1:配置数据库相关参数
properties的属性:${url}
-->
<!--<context:property-placeholder location="classpath:jdbc.properties"/>-->
<bean class="com.hacker.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>
<!-- 2 数据库连接池 id="abstractDataSource" abstract="true" destroy-method="close"-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
<!-- 配置连接池属性 -->
<property name="driverClass" value="${jdbc.driver}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<!-- c3p0 连接池的私有属性 -->
<property name="maxPoolSize" value="200"/>
<property name="minPoolSize" value="100"/>
<!-- 关闭连接后不自动commit -->
<property name="autoCommitOnClose" value="false"/>
<!-- 获取连接超时时间 -->
<property name="checkoutTimeout" value="1000"/>
<!-- 当获取连接失败重试次数 -->
<property name="acquireRetryAttempts" value="2"/>
</bean>
<!--<bean id="master" parent="abstractDataSource">
&lt;!&ndash; 配置连接池属性 &ndash;&gt;
<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">
&lt;!&ndash; 配置连接池属性 &ndash;&gt;
<property name="driverClass" value="${jdbc.driver}"/>
<property name="jdbcUrl" value="${jdbc.salve.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>-->
<!-- 配置动态数据源,targetDataSources就是路由数据源所对应的名称 -->
<!--<bean id="dynamicDataSource" class="com.hacker.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>-->
<!-- 约定大于配置 -->
<!-- 3 配置SQLSessionFactory对象 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource"/>
<!-- 配置MyBatis全局配置文件:mybatis-config.xml -->
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<!-- 扫描 entity 包 使用别名com.hacker.o2o.entity -->
<property name="typeAliasesPackage" value="com.hacker.o2o.entity"/>
<!-- 扫描sql配置文件:mapper需要的xml文件 -->
<property name="mapperLocations" value="classpath:mapper/*.xml"/>
</bean>
<!-- 4 配置扫描Dao接口包、动态实现dao接口、注入到spring容器中 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 注入sqlSessionFactory BeanName后处理方式 -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<!-- 给出扫描Dao接口包 -->
<property name="basePackage" value="com.hacker.o2o.dao"/>
</bean>
</beans>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/codezzz/JavaO2O.git
git@gitee.com:codezzz/JavaO2O.git
codezzz
JavaO2O
JavaO2O
master

搜索帮助