国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

SpringBoot發(fā)現(xiàn)最新版Druid重大問題(坑)

瀏覽:3日期:2023-04-20 15:43:35

發(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)!

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 贡嘎县| 榆社县| 昆明市| 武夷山市| 彭州市| 子洲县| 三原县| 大宁县| 沂源县| 务川| 博乐市| 枣庄市| 长沙市| 乌兰浩特市| 合川市| 科尔| 桓台县| 建宁县| 潍坊市| 广宗县| 安岳县| 泸水县| 宜州市| 樟树市| 怀宁县| 武汉市| 天镇县| 五指山市| 敦煌市| 镇平县| 大荔县| 肃南| 新竹县| 江西省| 华安县| 渝北区| 射洪县| 普格县| 聂荣县| 南投县| 胶州市|