baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.74k stars 1.19k forks source link

config.getConnectionProperties()可能出现空指针问题 #604

Closed qq592304796 closed 10 months ago

qq592304796 commented 10 months ago

Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。

Enviroment

JDK Version(required): 1.8

SpringBoot Version(required): 2.3.10.RELEASE

dynamic-datasource-spring-boot-starter Version(required):4.2.0

druid Version(optional):1.2.20

Describe what happened

config.getConnectionProperties()可能出现空指针问题 image image

Expected Result: connectProperties赋值前,进行初始化

Actual Result:

If there is an exception,or aop invalid,please attach the exception trace:

Just paste your stack trace here!

Steps to reproduce

huayanYu commented 10 months ago

大概什么样的配置会报错? 举个例子, 我去复现下啊

qq592304796 commented 10 months ago

大概什么样的配置会报错? 举个例子, 我去复现下啊

在配置了spring.datasource.dynamic.datasource.master.druid.public-key的情况下。但是没有配置spring.datasource.dynamic.druid.connection-properties就会出现

spring:
  datasource:
    dynamic:
      datasource:
        master:
          url: xxx
          username: xx
          password: xx
          driver-class-name: com.mysql.cj.jdbc.Driver
          druid:
            public-key: xxx

---
# 防止空指针问题
spring:
  datasource:
    dynamic:
      druid:
        # noinspection SpringBootApplicationYaml
        connection-properties: config.decrypt=true
huayanYu commented 10 months ago

4.3.0