<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 29.1.2. 連接生產環境數據庫 生產環境的數據庫連接可以通過池化的`DataSource`進行自動配置,下面是選取特定實現的算法: - 出于tomcat數據源連接池的優秀性能和并發,如果可用總會優先使用它。 - 如果HikariCP可用,我們將使用它。 - 如果Commons DBCP可用,我們將使用它,但生產環境不推薦。 - 最后,如果Commons DBCP2可用,我們將使用它。 如果使用`spring-boot-starter-jdbc`或`spring-boot-starter-data-jpa` 'starters',你會自動添加`tomcat-jdbc`依賴。 **注** 通過指定`spring.datasource.type`屬性,你可以完全拋棄該算法,然后指定數據庫連接池。如果你在tomcat容器中運行應用,由于默認提供`tomcat-jdbc`,這就很重要了。 **注** 其他的連接池可以手動配置,如果你定義自己的`DataSource` bean,自動配置是不會發生的。 DataSource配置被外部的`spring.datasource.*`屬性控制,例如,你可能會在`application.properties`中聲明以下片段: ```java spring.datasource.url=jdbc:mysql://localhost/test spring.datasource.username=dbuser spring.datasource.password=dbpass spring.datasource.driver-class-name=com.mysql.jdbc.Driver ``` **注** 你應該至少使用`spring.datasource.url`屬性指定url,或Spring Boot嘗試自動配置內嵌數據庫。 **注** 你經常不需要指定`driver-class-name`,因為Spring boot可以從`url`推斷大部分數據庫。 **注** 對于將要創建的池化`DataSource`,我們需要驗證是否有一個可用的`Driver`,所以在做其他事前會校驗它。比如,如果你設置`spring.datasource.driver-class-name=com.mysql.jdbc.Driver`,然后該class加載出來,否則就會出錯。 其他可選配置可以查看[DataSourceProperties](https://github.com/spring-projects/spring-boot/tree/v1.4.1.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java),有些標準配置是跟實現無關的,對于實現相關的配置可以通過相應前綴進行設置(`spring.datasource.tomcat.*`,`spring.datasource.hikari.*`,`spring.datasource.dbcp.*`和`spring.datasource.dbcp2.*`),具體參考你使用的連接池文檔。 例如,如果正在使用[Tomcat連接池](http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes),你可以自定義很多其他設置: ```properties # Number of ms to wait before throwing an exception if no connection is available. spring.datasource.tomcat.max-wait=10000 # Maximum number of active connections that can be allocated from this pool at the same time. spring.datasource.tomcat.max-active=50 # Validate the connection before borrowing it from the pool. spring.datasource.tomcat.test-on-borrow=true ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看