@Component
public class BaseConfigPath {
private static final String configPath = System.getProperty("user.home")+"/code/config";
public String getConfigPath() {
return configPath;
}
}
根据配置文件路径解析properties
<context:property-placeholder location="file:#{baseConfigPath.configPath}/jdbc.properties"/>
获取properties的属性值
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!-- 配置连接池属性 -->
<property name="driverClass" value="${jdbc.driverClassName}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<!-- c3p0连接池的私有属性 -->
<property name="maxPoolSize" value="30"></property>
<property name="minPoolSize" value="10"></property>
<!-- 关闭连接后不自动commit -->
<property name="autoCommitOnClose" value="false"></property>
<!-- 获取连接超时时间 -->
<property name="checkoutTimeout" value="1000"></property>
<!-- 当获取连接失败重试次数 -->
<property name="acquireRetryAttempts" value="2"></property>
</bean>
转载于:https://blog.51cto.com/12165865/2178860