springboot yml配置问题

他认为认为高峰时段个 发布于 2018/10/11 09:11
阅读 956
收藏 0

  在学习springboot用yml进行配置的时候有一个疑惑,例如:spring.datasource下的数据库最大等待时间,一些资料写的是max-wait,但是一些资料又写的是maxWait,个人觉得,从程序方面来说,这两个是完全不一样的字符串,所以不知道框架是对这两种写法都支持,还是其中一种写法其实是错误的(写法不对写了也不会生效)。如果都支持,最好能提供下大概是如何实现的

加载中
1
milin
milin

spring boot 2 官方文档,自己找下

 

```yml

# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.continue-on-error=false # Whether to stop if an error occurs while initializing the database.
spring.datasource.data= # Data (DML) script resource references.
spring.datasource.data-username= # Username of the database to execute DML scripts (if different).
spring.datasource.data-password= # Password of the database to execute DML scripts (if different).
spring.datasource.dbcp2.*= # Commons DBCP2 specific settings
spring.datasource.driver-class-name= # Fully qualified name of the JDBC driver. Auto-detected based on the URL by default.
spring.datasource.generate-unique-name=false # Whether to generate a random datasource name.
spring.datasource.hikari.*= # Hikari specific settings
spring.datasource.initialization-mode=embedded # Initialize the datasource with available DDL and DML scripts.
spring.datasource.jmx-enabled=false # Whether to enable JMX support (if provided by the underlying pool).
spring.datasource.jndi-name= # JNDI location of the datasource. Class, url, username & password are ignored when set.
spring.datasource.name= # Name of the datasource. Default to "testdb" when using an embedded database.
spring.datasource.password= # Login password of the database.
spring.datasource.platform=all # Platform to use in the DDL or DML scripts (such as schema-${platform}.sql or data-${platform}.sql).
spring.datasource.schema= # Schema (DDL) script resource references.
spring.datasource.schema-username= # Username of the database to execute DDL scripts (if different).
spring.datasource.schema-password= # Password of the database to execute DDL scripts (if different).
spring.datasource.separator=; # Statement separator in SQL initialization scripts.
spring.datasource.sql-script-encoding= # SQL scripts encoding.
spring.datasource.tomcat.*= # Tomcat datasource specific settings
spring.datasource.type= # Fully qualified name of the connection pool implementation to use. By default, it is auto-detected from the classpath.
spring.datasource.url= # JDBC URL of the database.
spring.datasource.username= # Login username of the database.
spring.datasource.xa.data-source-class-name= # XA datasource fully qualified name.
spring.datasource.xa.properties= # Properties to pass to the XA data source.

```

 

0
WilliamQ
WilliamQ

不同类型的数据库连接池读取的配置参数名不同,springboot如果没有指定数据库连接池,默认使用tomcat-jdbc连接池,其连接池参数配置:

spring.datasource.max-wait=10000
他认为认为高峰时段个
我意思是,有些资料(yml写法)写的是spring:datasource:maxWait,有些又写的是spring:datasource:max-wait,所以到底哪个才是正确的配置写法
0
木九天
木九天

这跟版本有关系的大兄dei

0
程序界小白
程序界小白

这个和yml文件没关系的,和spring boot中@ConfigurationProperties注解有关

返回顶部
顶部