无法在 Spring Boot 1.4 中设置 spring.datasource.type [英] Not able to set spring.datasource.type in spring boot 1.4
问题描述
问题是无法设置 spring.datasource.type",
The question is " Not able to set spring.datasource.type " ,
在 spring boot 1.3 中可以工作,但在 spring boot 1.4 中不能工作,不知道为什么?
In spring boot 1.3 can work , but in spring boot 1.4 can't work , I don't know why ?
以下是我的 application.properties:
The following is my application.properties:
spring.datasource.type= com.alibaba.druid.pool.DruidDataSource
spring.datasource.url = jdbc:mysql://localhost:3306/api-2016
spring.datasource.username = root
spring.datasource.password = root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.max-active=20
spring.datasource.max-idle=8
spring.datasource.min-idle=8
spring.datasource.initial-size=10
谁能告诉我为什么?
推荐答案
从 Spring Boot 1.4 开始,我们不再将 DataSource
实例映射到 spring.datasource
所以所有未应用自定义(max-active
等).
As of Spring Boot 1.4, we no longer map the DataSource
instance to spring.datasource
so all the customizations (max-active
, etc) aren't applied.
请阅读发布注释.DruidDataSource
上的自定义从未被支持,这是一个副作用.您可以通过创建自己的数据源 bean 来恢复该行为:
Please read the release notes. The customizations on DruidDataSource
were never supported and this was working as a side effect. You can restore that behaviour by creating your own datasource bean:
@Bean
@ConfigurationProprties("app.datasource.druid")
public DataSource dataSource() { ... }
并将您特定于德鲁伊的设置更改为 app.datasource.druid
.如果您启用 注解处理器 您将在 IDE 中获得这些密钥的内容帮助!
And change your druid-specific settings to app.datasource.druid
. If you enable the annotation processor you'll get content assistance in your IDE for those keys!
说完并查看代码后,我现在意识到我们有效地破坏了 spring.datasource.type
所以我创建了 #6695 跟踪该问题.
Having said that and poking at the code, I realize now that we effectively broke spring.datasource.type
so I've created #6695 to track that issue.
这篇关于无法在 Spring Boot 1.4 中设置 spring.datasource.type的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!