SpringBoot發(fā)現(xiàn)最新版Druid重大問題(坑)
發(fā)現(xiàn)Druid問題
最近做項(xiàng)目,遇到大量插入的地方,經(jīng)過大量的調(diào)試,最終發(fā)現(xiàn)是Druid連接池的問題,(以前一個(gè)大項(xiàng)目就遇到過Druid的坑),果斷換成c3p0之后,壓力測試嘩嘩上去了。
下面是更換c3p0方法。
1.修改pom.xml
導(dǎo)入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: truec3p0: 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;@Configurationpublic class DataSourceConfiguration { // c3p0 連接池 @Bean(name = 'dataSource') @Qualifier(value = 'dataSource') @Primary @ConfigurationProperties(prefix = 'c3p0') public DataSource dataSource() { return DataSourceBuilder.create().type(ComboPooledDataSource.class).build(); }}
打包,執(zhí)行:世界又恢復(fù)了和平!!
到此這篇關(guān)于SpringBoot發(fā)現(xiàn)最新版Druid重大問題(坑)的文章就介紹到這了,更多相關(guān)SpringBoot Druid內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. ASP中if語句、select 、while循環(huán)的使用方法2. ASP中解決“對象關(guān)閉時(shí),不允許操作。”的詭異問題……3. xml中的空格之完全解說4. php bugs代碼審計(jì)基礎(chǔ)詳解5. WMLScript的語法基礎(chǔ)6. ASP使用MySQL數(shù)據(jù)庫的方法7. msxml3.dll 錯(cuò)誤 800c0019 系統(tǒng)錯(cuò)誤:-2146697191解決方法8. html小技巧之td,div標(biāo)簽里內(nèi)容不換行9. XML入門的常見問題(四)10. ASP動(dòng)態(tài)網(wǎng)頁制作技術(shù)經(jīng)驗(yàn)分享
