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?
Spring Boot 在配置数据库连接池时优先选择 Tomcat 连接池,其次为 HikariCP 和 DBCP2。文章详细介绍了 Spring Boot 的连接池选择顺序及原因,并指出在使用特定 Starter 依赖时会自动引入 tomcat-jdbc 连接池。
677

被折叠的 条评论
为什么被折叠?



