程序员的资源宝库

网站首页 > gitee 正文

springboot数据库连接池使用策略(spring 数据库连接池配置)

sanyeah 2024-04-01 11:30:21 gitee 4 ℃ 0 评论

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.

  1. springboot会优先使用tomcat连接池,因为其性能和并发性很好,如果可用的话,将会优先使用。tomcat连接池,请查看: http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html
  2. 如果HikariCP可用,会选择使用 http://brettwooldridge.github.io/HikariCP/。
  3. 如果DBCP可用,会选择使用,但是不推荐在在先生产品使用它。
  4. 最后,如果使用DBCP2,会选择使用

    如果在pom文件里有spring-boot-starter-jdbc 或者 spring-boot-starter-data-jpa 依赖项,那么,会自动获取tomcat-jdbc连接池。

好像没有提到c3po?

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表