亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

SpringBoot2.0.3打印默認數(shù)據(jù)源為 HikariDataSource (null)問題

 更新時間:2021年10月08日 09:56:12   作者:nubipan  
這篇文章主要介紹了SpringBoot2.0.3打印默認數(shù)據(jù)源為 HikariDataSource (null)問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

SpringBoot2.0.3打印默認數(shù)據(jù)源為 HikariDataSource (null)

剛剛開始以為DataSource是空對象,后來打印了下面的語句,才知道DataSource不是空的,我砸,我就好奇為什么 打印出HikariDataSource (null) 這樣的語句,真的坑。

    @Autowired
    DataSource dataSource;
    @Autowired
    DataSourceProperties dataSourceProperties;
    @Test
    public void contextLoads() throws SQLException {
        System.out.println(String.format("數(shù)據(jù)源配置類:用戶名:%s,"
        +"密碼:%s,資源定位符:%s,驅(qū)動:%s"
                ,dataSourceProperties.getUsername(),
                dataSourceProperties.getPassword(),
                dataSourceProperties.getUrl(),
                dataSourceProperties.getDriverClassName()));
        System.out.println(dataSource == null);//結(jié)果為:false
        System.out.println("得到的數(shù)據(jù)源:"+dataSource);
        System.out.println("得到的連接:"+dataSource.getConnection());
    }

打印結(jié)果

得到的數(shù)據(jù)源:HikariDataSource (null) 2020-09-08 00:16:53.612 INFO 13316 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... Tue Sep 08 00:16:53 CST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 2020-09-08 00:16:54.330 INFO 13316 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.

得到的連接:HikariProxyConnection@722513129 wrapping com.mysql.jdbc.JDBC4Connection@52169758 2020-09-08 00:16:54.335 INFO 13316 --- [ Thread-2] o.s.w.c.s.GenericWebApplicationContext : Closing org.springframework.web.context.support.GenericWebApplicationContext@5b799640: startup date [Tue Sep 08 00:16:51 CST 2020]; root of context hierarchy 2020-09-08 00:16:54.337 INFO 13316 --- [ Thread-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2020-09-08 00:16:54.339 INFO 13316 --- [ Thread-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

需要注意

SpringBoot2.0.3使用的Driver是com.mysql.jdbc.Driver

springboot的HikariDataSource默認配置的默認值如下

name 構(gòu)造器默認值 默認配置validate之后的值 validate重置
minIdle -1 10 minIdle<0或者minIdle>maxPoolSize,則被重置為maxPoolSize
maxPoolSize -1 10 如果maxPoolSize小于1,則會被重置。當minIdle<=0被重置為DEFAULT_POOL_SIZE則為10;如果minIdle>0則重置為minIdle的值
maxLifetime MINUTES.toMillis(30) = 1800000 1800000 如果不等于0且小于30秒則會被重置回30分鐘
connectionTimeout SECONDS.toMillis(30) = 30000 30000 如果小于250毫秒,則被重置回30秒
validationTimeout SECONDS.toMillis(5) = 5000 5000 如果小于250毫秒,則會被重置回5秒
loginTimeout 10 30 Math.max(1, (int) MILLISECONDS.toSeconds(500L + connectionTimeout)),為connectionTimeout+500ms轉(zhuǎn)為秒數(shù)取整 與 1 取最大者
idleTimeout MINUTES.toMillis(10) = 600000 600000 如果idleTimeout+1秒>maxLifetime 且 maxLifetime>0,則會被重置為0;如果idleTimeout!=0且小于10秒,則會被重置為10秒
leakDetectionThreshold 0 0 如果大于0且不是單元測試,則進一步判斷:(leakDetectionThreshold < SECONDS.toMillis(2) or (leakDetectionThreshold > maxLifetime && maxLifetime > 0),會被重置為0 . 即如果要生效則必須>0,而且不能小于2秒,而且當maxLifetime > 0時不能大于maxLifetime
initializationFailTimeout 1 1 -
isAutoCommit true true -
isReadOnly false fasle -
isAllowPoolSuspension false false -
isIsolateInternalQueries false false -
isRegisterMbeans false false -
sealed false true 運行啟動后這個標志為true,表示不再運行修改
poolName null HikariPool-1 -
catalog null null -
connectionInitSql null null -
connectionTestQuery null null -
dataSourceClassName null null -
schema null null -
transactionIsolationName null null -
dataSource null null -
dataSourceProperties {} {} -
threadFactory null null -
scheduledExecutor null null -
metricsTrackerFactory null null -
metricRegistry null null -
healthCheckRegistry null null -
healthCheckProperties {} {} -
validation-query validationQuery屬性:用來驗證數(shù)據(jù)庫連接的語句,這個語句至少是返回一條數(shù)據(jù)的查詢語句。每種數(shù)據(jù)庫都有自己的驗證語句。以下是不同數(shù)據(jù)庫對應的驗證語句:

validation-query配置數(shù)據(jù)庫時,屬性validationQuery默認值為“select 1”,對于oracle值應為“select 1 from dual”

validationQuery屬性:用來驗證數(shù)據(jù)庫連接的語句,這個語句至少是返回一條數(shù)據(jù)的查詢語句。每種數(shù)據(jù)庫都有自己的驗證語句。

以下是不同數(shù)據(jù)庫對應的驗證語句:

DataBase validationQuery
hsqldb select 1 from INFORMATION_SCHEMA.SYSTEM_USERS
Oracle select 1 from dual
DB2 select 1 from sysibm.sysdummy1
MySql select 1
Microsoft SqlServer select1
postgresql select version()
ingres select 1
derby values 1
H2 select 1

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Spring之異步任務@Async解讀

    Spring之異步任務@Async解讀

    這篇文章主要介紹了Spring之異步任務@Async,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • SpringCloud微服務熔斷器Hystrix使用詳解

    SpringCloud微服務熔斷器Hystrix使用詳解

    這篇文章主要介紹了Spring Cloud Hyxtrix的基本使用,它是Spring Cloud中集成的一個組件,在整個生態(tài)中主要為我們提供服務隔離,服務熔斷,服務降級功能,本文給大家介紹的非常詳細,需要的朋友可以參考下
    2022-07-07
  • Java設計模式之單例模式

    Java設計模式之單例模式

    這篇文章主要給大家介紹了關(guān)于Java單例模式,文中通過示例代碼介紹的非常詳細,對大家學習或者使用Java具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2021-10-10
  • java統(tǒng)計字符串中指定元素出現(xiàn)次數(shù)方法

    java統(tǒng)計字符串中指定元素出現(xiàn)次數(shù)方法

    這篇文章主要介紹了java統(tǒng)計字符串中指定元素出現(xiàn)次數(shù)方法,需要的朋友可以參考下
    2015-12-12
  • 通過java記錄數(shù)據(jù)持續(xù)變化時間代碼解析

    通過java記錄數(shù)據(jù)持續(xù)變化時間代碼解析

    這篇文章主要介紹了通過java記錄數(shù)據(jù)持續(xù)變化時間代碼解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-01-01
  • Spring?Boot?整合?FreeMarker?實例分享

    Spring?Boot?整合?FreeMarker?實例分享

    這篇文章主要分享了Spring?Boot整合FreeMarker?實例FreeMarker是一款模板引擎,即一種基于模板和要改變的數(shù)據(jù),并用來生成輸出文本,更多相關(guān)介紹需要的小伙伴可以參考下面文章內(nèi)容
    2022-05-05
  • java中CompleteFuture與Future的區(qū)別小結(jié)

    java中CompleteFuture與Future的區(qū)別小結(jié)

    本文主要介紹了java中CompleteFuture與Future的區(qū)別小結(jié),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-12-12
  • 淺談Java讀寫注冊表的方式Preferences與jRegistry

    淺談Java讀寫注冊表的方式Preferences與jRegistry

    這篇文章主要介紹了淺談Java讀寫注冊表的方式Preferences與jRegistry,分享了相關(guān)代碼示例,小編覺得還是挺不錯的,具有一定借鑒價值,需要的朋友可以參考下
    2018-02-02
  • Java UrlRewriter偽靜態(tài)技術(shù)運用深入分析

    Java UrlRewriter偽靜態(tài)技術(shù)運用深入分析

    通常我們?yōu)榱烁玫木徑夥掌鲏毫?和增強搜索引擎的友好面,都將文章內(nèi)容生成靜態(tài)頁面,這就產(chǎn)生了偽靜態(tài)技術(shù),也就是我們常說的Url Rewriter重寫技術(shù)
    2012-12-12
  • springboot啟動時運行代碼詳解

    springboot啟動時運行代碼詳解

    在本篇內(nèi)容中我們給大家整理了關(guān)于在springboot啟動時運行代碼的詳細圖文步驟以及需要注意的地方講解,有興趣的朋友們學習下。
    2019-06-06

最新評論