简体   繁体   English

如何在SpringBoot 2.0应用程序中打印spring数据源值

[英]How to print spring datasource values in SpringBoot 2.0 application

I want to see all the default/set values for spring datasource. 我想查看spring数据源的所有默认/设置值。 I am using SpringBoot 2.0. 我正在使用SpringBoot 2.0。

Can someone please tell me know to print these values in a java applications. 有人可以告诉我知道如何在Java应用程序中打印这些值。

Reason I am asking because I want to find whether the property I added to my application.yml is overwriting the default values 之所以问我,是因为我想查找添加到application.yml中的属性是否覆盖了默认值

application.yml is as below application.yml如下

.
.
.
.
        spring:
          datasource:
            url: ${vcap.services.cas-db.credentials.url}
            username: ${vcap.services.cas-db.credentials.username}
            password: ${vcap.services.cas-db.credentials.password}
.
.
.
.

I have not mentioned parameters such as hikari connectionTimeout in my yml file. 我没有在yml文件中提及诸如hikari connectionTimeout之类的参数。 If want to print the values for these parameters 如果要打印这些参数的值

For Spring Boot 1.5 try this datasource type : org.apache.tomcat.jdbc.pool.DataSource (I'm not 100% sure). 对于Spring Boot 1.5,请尝试以下数据源类型: org.apache.tomcat.jdbc.pool.DataSource (我不确定100%)。 If you defined your own datasource using javax.sql.DataSource so use this one. 如果您使用javax.sql.DataSource定义了自己的数据源,那么请使用此数据源。

Since Spring Boot 2.0, default datasource is com.zaxxer.hikari.HikariDataSource . 从Spring Boot 2.0开始,默认数据源为com.zaxxer.hikari.HikariDataSource

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM