SSH整合时applicationContext.xml的配置(数据源用C3P0连接池)
2010-09-29 13:57
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
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-2.0.xsd">
<bean id="data" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:dataSource.properties"></property>
</bean>
<!-- 使用C3P0连接池的配置 Rain -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!--这些数据库的连接参数(name值)与原来的不大一样-->
<property name="driverClass" value="${driverClassName}"/>
<property name="jdbcUrl" value="${url}"/>
<property name="user" value="${username}"/>
<property name="password" value="${password}"/>
<!--连接池中保留的最小连接数。-->
<property name="minPoolSize">
<value>5</value>
</property>
<!--连接池中保留的最大连接数。Default: 15 -->
<property name="maxPoolSize" value="30"/>
<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<property name="initialPoolSize" value="10"/>
<!--最大空闲时间,600秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime" value="600"/>
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<property name="acquireIncrement" value="5"/>
<!--JDBC的标准参数,用以控制数据源内加载的PreparedStatements数量。但由于预缓存的statements 属于单个connection而不是整个连接池。所以设置这个参数需要考虑到多方面的因素。 如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0-->
<property name="maxStatements" value="0"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"></ref>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<!-- 设置二级缓冲 -->
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<!-- 设置二级缓冲,打开查询缓冲 -->
<prop key="hbm2ddl.auto">create</prop>
<!-- <prop key="hibernate.format_sql">true</prop> -->
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<!-- ******* 将vo导入到applicationContext中 Rain ****** -->
<!-- ******* 税源-土地模块模块 ****** -->
<value>edu/rtax/vo/shuiyuan/tudixinxi/Dwxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/tudixinxi/Nsrxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/tudixinxi/Tdjbxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/tudixinxi/Tdjyxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/tudixinxi/Xxb.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/tudixinxi/Gexx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/tudixinxi/Tdzjxxb.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/jianan/Jagcxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/jianan/Jasrxx.hbm.xml</value>
<!-- ******* rain ****** -->
<value>edu/rtax/vo/shezhi/Users.hbm.xml</value>
<value>edu/rtax/vo/shezhi/Employee.hbm.xml</value>
<value>edu/rtax/vo/shezhi/Roles.hbm.xml</value>
<value>edu/rtax/vo/shezhi/GongNengDian.hbm.xml</value>
<value>edu/rtax/vo/shezhi/MapList.hbm.xml</value>
<value>edu/rtax/vo/shezhi/MapMark.hbm.xml</value>
<value>edu/rtax/vo/shezhi/MapXzqh.hbm.xml</value>
<value>edu/rtax/vo/shezhi/Xzqhdm.hbm.xml</value>
<value>edu/rtax/vo/shezhi/CessCode.hbm.xml</value>
<!-- ****** 税源模块 不动产与寸量房 ****** -->
<value>edu/rtax/vo/shuiyuan/Bdcjyxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Bdcldxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Xmjbxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Fwjysr.hbm.xml</value>
<value>edu/rtax/vo/shezhi/DataDictionary.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Fwjbxxb.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Fwxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Esfjyxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Esfzjxxb.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Zlfjyxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Zlfzjxx.hbm.xml</value>
<value>edu/rtax/vo/shuiyuan/Zlfszmx.hbm.xml</value>
<!-- ****** 档案管理模块 ****** -->
<value>edu/rtax/vo/dangan/Dadmlxx.hbm.xml</value>
<value>edu/rtax/vo/dangan/Dadxx.hbm.xml</value>
<value>edu/rtax/vo/dangan/Dagcxx.hbm.xml</value>
<value>edu/rtax/vo/dangan/Dagxx.hbm.xml</value>
<value>edu/rtax/vo/dangan/Dasjb.hbm.xml</value>
<value>edu/xinzhen/vo/Xzqs.hbm.xml</value>
<value>edu/xinzhen/vo/Jyxzqh.hbm.xml</value>
<value>edu/rtax/vo/dangan/Document.hbm.xml</value>
<value>edu/rtax/vo/dangan/Document_file.hbm.xml</value>
</list>
</property>
</bean>
<!-- 附属的vo配置文件 -->
<import resource="classpath:vo_chaxun.xml"/>
<import resource="classpath:vo_dangan.xml"/>
<import resource="classpath:vo_dangan2.xml"/>
<import resource="classpath:vo_shezhi.xml"/>
<import resource="classpath:vo_shuiyuan.xml"/>
<import resource="classpath:vo_xingzheng.xml"/>
</beans>
|
|
spring配置文件applicationContext.xml配置hibernate的连接数据库信息及sessionFactory创建方式
2010-06-29 10:47
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
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-2.0.xsd">
<!-- apache.dbcp连接池的配置 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/s2sh?useUnicode=true&characterEncoding=UTF-8"></property>
<property name="username" value="root"></property>
<property name="password" value=""></property>
<!-- 最大活动连接数 -->
<property name="maxActive" value="100"></property>
<!-- 最大可空闲连接数 -->
<property name="maxIdle" value="30"></property>
<!-- 最大可等待连接数 -->
<property name="maxWait" value="500"></property>
<!-- 默认的提交方式(如果不需要事务可以设置成true,在实际应用中一般设置为false,默认为false) -->
<property name="defaultAutoCommit" value="true"></property>
</bean>
<!-- 这里直接使用spring对hibernate3支持的sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!-- hibernate方言等相关配置 -->
<property name="hibernateProperties">
<props>
<prop key="connection.useUnicode">true</prop>
<prop key="connection.characterEncoding">utf-8</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<!-- hbm.xml的映射文件 -->
<property name="mappingResources">
<list>
<value>test/s2sh/bean/Person.hbm.xml</value>
</list>
</property>
</bean>
|