springboot官方文檔介紹數據庫連接池的使用策略如下:
Production database connections can also be auto-configured using a
pooling DataSource. Here’s the algorithm for choosing a specific
implementation:
We prefer the Tomcat pooling DataSource for its performance and concurrency, so if that is available we always choose it.
If HikariCP is available we will use it.
If Commons DBCP is available we will use it, but we don’t recommend it in production.
Lastly, if Commons DBCP2 is available we will use it.
If you use the spring-boot-starter-jdbc or spring-boot-starter-data-jpa ‘starter
POMs’ you will automatically get a dependency to tomcat-jdbc.
- springboot會優先使用tomcat連接池,因為其性能和並發性很好,如果可用的話,將會優先使用。tomcat連接池,請查看: http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html
- 如果HikariCP可用,會選擇使用 http://brettwooldridge.github.io/HikariCP/。
- 如果DBCP可用,會選擇使用,但是不推薦在在先生產品使用它。
-
最后,如果使用DBCP2,會選擇使用
如果在pom文件里有spring-boot-starter-jdbc 或者 spring-boot-starter-data-jpa 依賴項,那么,會自動獲取tomcat-jdbc連接池。
好像沒有提到c3po?
