alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.07k stars 12.81k forks source link

nacos配置中心共享配置无法读取配置 #10590

Closed MaLuxray closed 1 year ago

MaLuxray commented 1 year ago

springboot version 2.6.0 springcloud version 3.1.4 nacosconfig version 2021.1

bootstrap.yml

    spring:
       application:
           name: config-app
       cloud:
         nacos:
            server-addr: locahost:8848
            config:
               group: DEFAULT_GROUP
               prefix: ${spring.application.name}
               file-extension: yaml
               extension-configs:
                - data-id: redis

配置中心 redis 配置

    redis:
       host: 127.0.0.1
       username: amdin
       password: admin
    name: redis

配置中心 config-app` 配置

   server:
      port: 15555

java code

   @RestController
    public class RedisController {
       @Value("${redis.host}")
       private String redisValue;

       @GetMapping(value = "/redis")
        public String redis() {
           return redisValue;
       }
   }

启动服务时报错

   Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'redis.host' in value "${redis.host}"

当把reids.host改成name又可以正常启动

KomachiSion commented 1 year ago

It seems nacos has push the config into application, but spring cloud can't parse redis.host . Please move issue to SCA community. From current information it's not nacos' problem.