Spring引入配置文件

2021-07-10 18:07

阅读:342

标签:时间   data   temp   ignore   rom   color   table   alibaba   filter   

1.spring.xml加载映射的配置配置文件

 
    context:property-placeholder location="classpath:db.properties"/>

2.加载多个配置文件

 
    bean id="propertyConfigurer"
          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:db.propertiesvalue>
            list>
        property>
    bean>

3.在配置文件中可以引用

 bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
        property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        property name="url" value="${jdbc.url}"/>
        property name="username" value="${jdbc.username}"/>
        property name="password" value="${jdbc.password}"/>
        
        property name="initialSize" value="10" />
        property name="minIdle" value="5" />
        property name="maxActive" value="200" />
        
        property name="maxWait" value="60000" />
        property name="removeAbandoned" value="true" />
        property name="removeAbandonedTimeout" value="180" />
        
        property name="timeBetweenEvictionRunsMillis" value="10000" />
        property name="validationQuery" value="SELECT ‘x‘ from dual"/>
        property name="logAbandoned" value="true" />
        
        property name="minEvictableIdleTimeMillis" value="300000" />
        
        property name="testOnBorrow" value="false" />
        property name="testOnReturn" value="false" />
        
        property name="poolPreparedStatements" value="true" />
        property name="maxPoolPreparedStatementPerConnectionSize"
                  value="20" />

        property name="defaultAutoCommit" value="true" />
        property name="filters" value="stat,wall"/>
        property name="proxyFilters">
            list>
                ref bean="log-filter"/>
            list>
        property>
    bean>

 

Spring引入配置文件

标签:时间   data   temp   ignore   rom   color   table   alibaba   filter   

原文地址:https://www.cnblogs.com/sagech/p/9555113.html


评论


亲,登录后才可以留言!