applicationContest.xml
<?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-lazy-init="true">
<description>Spring公共配置文件 </description>
<!-- 定义受环境影响易变的变量 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<!-- 标准配置 -->
<value>classpath*:/application.properties</value>
<!-- 本地开发环境配置,根据需要配制 -->
<!--<value>classpath*:/application.local.properties</value>-->
<!-- 服务器生产环境配置,根据需要配制 -->
<!-- <value>file:/var/myapp/application.server.properties</value> -->
</list>
</property>
</bean>
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan base-package="com.fastrise" />
<!-- 数据源配置 DBCP数据库连接池-->
<!--<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
Connection Info
<property name="driverClassName" value="${jdbc.driverClass}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
Connection Pooling Info
<property name="initialSize" value="5" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="1000" />
<property name="poolPreparedStatements" value="true" />
<property name="defaultAutoCommit" value="true" />
Validate 数据库断开连接自动重连检测
<property name="testWhileIdle" value="true"/>
<property name="testOnBorrow" value="false"/>
<property name="testOnReturn" value="false"/>
<property name="validationQuery" value="select sysdate from dual"/>
<property name="timeBetweenEvictionRunsMillis" value="30000"/>
<property name="numTestsPerEvictionRun" value="20"/>
</bean>
-->
<bean id="dataSource" class="com.fastrise.fastdev.base.ext.connection.ProxoolDataSourceExt">
<property name="driver" value="${jdbc.driverClass}"/>
<property name="driverUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<!-- 测试的SQL执行语句 -->
<property name="houseKeepingTestSql" value="select sysdate from dual"/>
<!-- 最少保持的空闲连接数 (默认2个) -->
<property name="prototypeCount" value="5"/>
<!-- proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁 默认30秒) -->
<property name="houseKeepingSleepTime" value="30000"/>
<!-- 最大活动时间(超过此时间线程将被kill,默认为5分钟) -->
<property name="maximumActiveTime" value="300000"/>
<!-- 最小连接数 (默认2个) -->
<property name="minimumConnectionCount" value="20"/>
<!-- 最大连接数 (默认5个) -->
<property name="maximumConnectionCount" value="100"/>
<!-- 别名 -->
<property name="alias" value="${jdbc.username}"/>
<!-- -->
<property name="simultaneousBuildThrottle" value="20"/>
</bean>
<!--<bean id="dataSource" class="com.p6spy.engine.spy.P6DataSource">
<constructor-arg ref="proxoolDataSource" />
</bean>
--><!-- Hibernate 配置 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">${hibernate.ehcache_config_file}</prop>
<!-- hibernate search configure -->
<!-- <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>-->
<!-- <prop key="hibernate.search.default.indexBase">/lucene/indexes</prop>-->
</props>
</property>
<!-- <property name="packagesToScan">-->
<!-- <list>-->
<!-- <value>com.fastrise.**.model</value>-->
<!-- </list>-->
<!-- </property>-->
</bean>
<!-- Ibatis 配置 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:sql-map-config.xml</value>
</property>
<property name="mappingLocations">
<value>classpath*:/com/fastrise/**/*SqlMap.xml</value>
</property>
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- 事务管理器配置,单数据源事务 -->
<!--
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- 事务管理器配置,多数据源JTA事务-->
<!--
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager or
WebLogicJtaTransactionManager" />
-->
<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- hibernate DAO操作封装 -->
<bean id="hibernateDao" class="com.fastrise.fastdev.base.dao.hibernate.BaseHibernateDao">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- ibatis DAO操作封装 -->
<bean id="ibatisDao" class="com.fastrise.fastdev.base.dao.ibatis.BaseIbatisDao">
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>
<!--<bean id="sequenceDao" class="com.fastrise.fastdev.base.dao.ibatis.SequenceSqlMapDao">
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>
-->
<bean id="sequenceDao" class="com.fastrise.fastdev.base.dao.ibatis.OracleSequenceDao">
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>
<bean id="systemLogAspect" class="com.fastrise.fastdev.system.web.aop.SystemLogAspect"/>
<!-- 使用@AspectJ自动代理 -->
<aop:aspectj-autoproxy proxy-target-class="true"/>
</beans>
application.properties
#Public attribute configuration file
#jdbc setting
#oracle
jdbc.driverClass=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@192.168.100.100:1521:wlb
#jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
jdbc.username=fjrz
jdbc.password=raw_Zmpyeg==
#jdbc.url=jdbc:oracle:thin:@localhost:1521:ORACL
#hibernate setting
hibernate.dialect=org.hibernate.dialect.Oracle9iDialect
#hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2ddl.auto=false
hibernate.ehcache_config_file=/ehcache/ehcache-hibernate-local.xml
#jmx setting
server.host=localhost