【问题标题】:Not able to set spring.datasource.type in spring boot 1.4无法在 Spring Boot 1.4 中设置 spring.datasource.type
【发布时间】:2016-12-26 05:18:05
【问题描述】:

问题是“无法设置spring.datasource.type”,

在spring boot 1.3可以工作,但是在spring boot 1.4不能工作,不知道为什么?

以下是我的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】:

    从 Spring Boot 1.4 开始,我们不再将 DataSource 实例映射到 spring.datasource,因此不会应用所有自定义项(max-active 等)。

    请阅读the release notesDruidDataSource 上的自定义从未得到支持,这是一个副作用。您可以通过创建自己的数据源 bean 来恢复该行为:

    @Bean
    @ConfigurationProprties("app.datasource.druid")
    public DataSource dataSource() { ... }
    

    并将您的德鲁伊特定设置更改为app.datasource.druid。如果您启用 annotation processor,您将在 IDE 中获得这些密钥的内容帮助!

    话虽如此并查看代码,我现在意识到我们有效地破坏了spring.datasource.type,因此我创建了#6695 来跟踪该问题。

    【讨论】:

    • 我知道spring boot 1.2不支持,1.3支持,为什么1.4取消支持?
    猜你喜欢
    • 2015-12-26
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 2018-03-20
    • 2022-11-02
    • 2021-12-16
    • 1970-01-01
    相关资源
    最近更新 更多