nacos-group / nacos-spring-project

Nacos ECO Project for Spring Framework
https://nacos.io/
Apache License 2.0
756 stars 311 forks source link

@nacosConfigListener Properties 类型转换失效 #302

Open misaya98 opened 1 year ago

misaya98 commented 1 year ago

Issue Description

@NacosConfigListener Properties 类型转换失效

Type: bug report

Describe what happened (or what feature you want)

application.yml:

spring:
  config:
    import:
      - nacos:nacos-boot
  cloud:
    nacos:
      config:
        file-extension: yaml
        server-addr: 127.0.0.1:8848

code:

    @NacosConfigListener(dataId = "nacos-boot",type = ConfigType.YAML)
    public void onMessage(String configInfo){
        log.info("NacosConfigListener#String"+ configInfo);
    }
    @NacosConfigListener(dataId = "nacos-boot",type = ConfigType.YAML)
    public void onMessage1(Properties configInfo){
        log.info("NacosConfigListener#Properties"+ configInfo.toString());
    }

when changed the config from nacos, output:

2023-01-09 21:06:01.333  INFO 14328 --- [onfigListener-1] c.e.c.controller.TestController          : NacosConfigListener#Stringuser:
  name: test-user
  age: 99
2023-01-09 21:06:01.578  INFO 14328 --- [ternal.notifier] c.a.c.n.c.NacosConfigDataLoader          : [Nacos Config] Load config[dataId=nacos-boot, group=DEFAULT_GROUP] success

expected output:

both  NacosConfigListener#String and  NacosConfigListener#Properties should be triggerd

Tell us your environment

spring cloud version : 2021.0.4 springboot version : 2.7.5 nacos version : 2.2.0