在尝试spring cloud config server git集成时,无法从客户端配置连接到spring cloud config server

8zzbczxx  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(187)

我正在尝试springcloud与git的集成,以管理外部文件中的更改,而无需应用程序跳出本教程springboot2.4.3。配置服务器已启动,但无法通过客户端连接到属性。

application.properties (config-client app)
spring.application.name=config-client
spring.cloud.config.uri=http://localhost:8888/
spring.profiles.active=production
management.security.enabled=false

客户机代码

@SpringBootApplication
public class ConfigClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConfigClientApplication.class, args);
    }

    @Autowired
    public void setEnv(Environment e)
    {
        System.out.println(e.getProperty("msg"));
    }

    @RestController
    @RefreshScope
    class ExampleController {

        @Value("${msg:Config Server is not working. Please check.again.}")
        private String msg;

        @RequestMapping("/msg")
        public String sayValue() {
            return msg;
        }
    }
}

它总是传递信息” Config Server is not working. Please check.again ". 我哪里出了问题有什么帮助吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题