代碼片段,用於配置Spring中的applicationContext文件,直接修改其中的配置即可
<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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
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-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
<!-- 對Spring中的Bean進行配置 -->
<!-- 使用spring自帶的佔位符替換功能,可以實現註解方式獲取屬性文件中的配置值 -->
<bean class="cn.tineaine.summer.common.spring.exetend.ExtendedPropertyPlaceholderConfigurer">
<!-- 允許JVM參數覆蓋 -->
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<!-- 忽略沒有找到的資源文件 -->
<property name="ignoreResourceNotFound" value="true" />
<!-- 配置資源文件 -->
<property name="locations">
<list>
<!-- JDBC -->
<value>classpath:jdbc.properties</value>
<!-- 環境 -->
<value>classpath:env.properties</value>
<!-- redis -->
<value>classpath:redis.properties</value>
<!-- HttpClient -->
<value>classpath:httpclient.properties</value>
<!-- rabbitmq -->
<value>classpath:rabbitmq.properties</value>
</list>
</property>
</bean>
<!-- 指定要在哪些位置掃描包 -->
<context:component-scan base-package="cn.tineaine.summer" />
<!-- 配置數據庫連接池 -->
<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
<!-- 數據庫驅動 -->
<property name="driverClass" value="${jdbc.driver}" />
<!-- 相應驅動的jdbcUrl -->
<property name="jdbcUrl" value="${jdbc.url}" />
<!-- 數據庫用戶名 -->
<property name="username" value="${jdbc.username}" />
<!-- 數據庫密碼 -->
<property name="password" value="${jdbc.password}" />
<!-- 檢查連接池中空閒連接的間隔時間,單位是分,默認240,0爲不檢查 -->
<property name="idleConnectionTestPeriod" value="60" />
<!-- 連接池中未使用的鏈接最大存活時間,單位是分,默認:60,0爲永遠存活 -->
<property name="idleMaxAge" value="30" />
<!-- 每個分區最大的連接數 -->
<property name="maxConnectionsPerPartition" value="150" />
<!-- 每個分區最小的連接數 -->
<property name="minConnectionsPerPartition" value="5" />
</bean>
</beans>