SpringBoot發現最新版Druid重大問題
SpringBoot使用C3P0連線池
發現Druid問題
最近做專案,遇到大量插入的地方,經過大量的除錯,最終發現是Druid連線池的問題,(以前一個大專案就遇到過Druid的坑),果斷換成c3p0之後,壓力測試嘩嘩上去了。
下面是更換c3p0方法。
1.修改pom.xml
匯入c3p0依賴:
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.5</version>
</dependency>
2.修改application.yml
spring:
application:
name: nh-tst
http:
encoding:
charset: UTF-8
enabled: true
force: true
datasource:
driver-class-name: oracle.jdbc.driver.OracleDriver
jpa:
hibernate:
ddl-auto: none
show-sql: true
c3p0:
jdbcUrl: jdbc:oracle:thin:@xxxxx:1522/prodpdb1
user: xxxxxx
password: xxxxxx
driverClass: oracle.jdbc.driver.OracleDriver
minPoolSize: 3
maxPoolSize: 30
maxIdleTime: 1800000
acquireIncrement: 120
maxStatements: 100000
initialPoolSize: 5
idleConnectionTestPeriod: 60
acquireRetryAttempts: 30
acquireRetryDelay: 10000
breakAfterAcquireFailure: false
testConnectionOnCheckout: false
3.增加DataSourceConfiguration.java類
package com.nh.fk.tst.config;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import com.mchange.v2.c3p0.ComboPooledDataSource;
@Configuration
public class DataSourceConfiguration {
// c3p0 連線池
@Bean(name = "dataSource")
@Qualifier(value = "dataSource")
@Primary
@ConfigurationProperties(prefix = "c3p0")
public DataSource dataSource() {
return DataSourceBuilder.create().type(ComboPooledDataSource.class).build();
}
}
打包,執行:世界又恢復了和平!!
相關文章
- springboot+mybatisplus+druid資料來源:SQLException問題Spring BootMyBatisUISQLException
- springboot整合druidSpring BootUI
- SpringBoot整合Mybatis+DruidSpring BootMyBatisUI
- SpringBoot_1_integrate_DruidSpring BootUI
- Druid.io SQL亂碼問題UISQL
- SpringBoot資料訪問之Druid啟動器的使用Spring BootUI
- SpringBoot3.x使用DruidSpring BootUI
- SpringBoot資料訪問之Druid資料來源的使用Spring BootUI
- SpringBoot整合mybatis出現時區問題Spring BootMyBatis
- springboot對接mqtt出現的問題Spring BootMQQT
- dubbo繼承springboot出現的問題繼承Spring Boot
- springboot整合Druid資料來源[springboot8]Spring BootUI
- Druid連線池引數maxWait配置錯誤引發的問題UIAI
- IDEA開發SpringBoot專案問題集IdeaSpring Boot
- SpringBoot整合Druid資料來源Spring BootUI
- springboot+mybatis+druid實現mysql主從讀寫分離(五)Spring BootMyBatisUIMySql
- SpringBoot整合阿里巴巴Druid監控Spring Boot阿里UI
- springBoot初學出現問題 {dataSource-1} initedSpring Boot
- springboot 跨域問題Spring Boot跨域
- 發現一個問題
- 中國科協:2021年三十個重大問題難題
- Springboot+logback+druid +密碼加密 實現業務日誌入庫Spring BootUI密碼加密
- 單手擼了個springboot+mybatis+druidSpring BootMyBatisUI
- SpringBoot專案整合阿里Druid連線池Spring Boot阿里UI
- springboot 配置DRUID資料來源的方法Spring BootUI
- Springboot專案引入druid安裝部署使用Spring BootUI
- Springboot進階-JDBC、Druid、Mybatis、Swagger、SpringMVC、MailSpring BootJDBCUIMyBatisSwaggerSpringMVCAI
- SpringBoot 整合多資料來源(MyBatis + Druid)Spring BootMyBatisUI
- Flowable與springBoot專案整合及出現的問題Spring Boot
- springboot使用問題總結Spring Boot
- SpringBoot遇到的某些問題Spring Boot
- SpringBoot-相關問題Spring Boot
- SpringBoot mysql驅動問題Spring BootMySql
- springboot+ mybatisplus+druid 實現多資料來源+分散式事務Spring BootMyBatisUI分散式
- SpringBoot+Mybatis+ Druid+PageHelper 實現多資料來源並分頁Spring BootMyBatisUI
- 2020.09 問題總結(Oracle-->MySQL、Maven、JSP-->Thymeleaf、Druid)OracleMySqlMavenJSUI
- springboot中加入druid對sql進行監控Spring BootUISQL
- Springboot 整合阿里資料庫連線池 druidSpring Boot阿里資料庫UI