代码片段,用于配置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>