spring資料庫鏈串連池配置屬性詳解(druid)__JAVA

來源:互聯網
上載者:User
<!-- 配置資料來源 -->    <!-- 載入資料庫的設定檔jdbc.properties 詳解在最後 -->   <context:property-placeholder location="classpath:jdbc.properties" />    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"        init-method="init" destroy-method="close">        <!-- 基本屬性 驅動 url、user、password  -->        <property name="driverClassName" value="${jdbc.driverClassName}"></property>        <property name="url" value="${jdbc.url}"></property>        <property name="username" value="${jdbc.username}"></property>        <property name="password" value="${jdbc.password}"></property>        <!-- 配置初始化大小、最小、最大 -->        <property name="initialSize" value="1" />        <property name="minIdle" value="1" />        <property name="maxActive" value="20" />        <!-- 配置擷取串連等待逾時的時間 -->        <property name="maxWait" value="60000" />        <!-- 配置間隔多久才進行一次檢測,檢測需要關閉的空閑串連,單位是毫秒 -->        <property name="timeBetweenEvictionRunsMillis" value="60000" />        <!-- 配置一個串連在池中最小生存的時間,單位是毫秒 -->        <property name="minEvictableIdleTimeMillis" value="300000" />        <property name="validationQuery" value="SELECT 'x'" />        <property name="testWhileIdle" value="true" />        <property name="testOnBorrow" value="false" />        <property name="testOnReturn" value="false" />        <!-- 開啟PSCache,並且指定每個串連上PSCache的大小 -->        <property name="poolPreparedStatements" value="true" />        <property name="maxPoolPreparedStatementPerConnectionSize"            value="20" />        <!-- 配置監控統計攔截的filters -->        <property name="filters" value="wall,stat" />    </bean><!--載入jdbc設定檔詳解--!>參考  http://blog.csdn.net/Rickesy/article/details/50791534
Spring設定檔<context:property-placeholder>標籤使用淺談<context:property-placeholder
        location=""          file-encoding=""          ignore-resource-not-found=""          ignore-unresolvable=""          properties-ref=""          local-override=""          system-properties-mode=""          order=""  /> location:表示屬性檔案位置,多個之間通過如逗號/分號等分隔; file-encoding:檔案編碼; ignore-resource-not-found:如果屬性檔案找不到,是否忽略,預設false,即不忽略,找不到將拋出異常 ignore-unresolvable:是否忽略解析不到的屬性,如果不忽略,找不到將拋出異常 properties-ref:本地java.util.Properties配置 local-override:是否本地覆蓋模式,即如果true,那麼properties-ref的屬性將覆蓋location載入的屬性 system-properties-mode:系統屬性模式,ENVIRONMENT(預設),NEVER,OVERRIDE    ENVIRONMENT:將使用Spring 3.1提供的PropertySourcesPlaceholderConfigurer,其他情況使用Spring 3.1之前的PropertyPlaceholderConfigurer    OVERRIDE: PropertyPlaceholderConfigurer使用,因為在spring 3.1之前版本是沒有Enviroment的,所以OVERRIDE是spring 3.1之前版本的Environment    NEVER:只尋找properties-ref、location; order:當配置多個<context:property-placeholder/>時的尋找順序




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.