gpt4 book ai didi

java - 环境特定的 Eureka 属性未加载

转载 作者:行者123 更新时间:2023-12-02 10:03:13 26 4
gpt4 key购买 nike

我使用 spring Cloud 1.5.17 版本创建了一个 Eureka 客户端和服务器项目。这两个项目都工作正常,但问题是,根据环境,我希望在客户端项目运行时加载某些 Eureka 属性。为此,我所做的是为 Eureka 创建了环境特定的属性文件,如下所示。

enter image description here

我已在 application.yml 中尝试了以下所有三个属性,但似乎没有一个没有选择 eureka-client-test.properties 属性

spring:
profiles:
active: test

eureka:
instance:
environment: test

eureka:
instance:
environment:
active-profiles:
- test

谁能帮我解决这个问题

完整的源代码已提交,可在下面的 bitbucket 存储库中获取

https://bitbucket.org/resh32/eureka

最佳答案

覆盖此属性 eureka.client.props与您的属性文件名不带 .properties后缀。

假设您使用 spring.profiles.active 指定您的 spring Activity 环境&然后对应application-env.properties您可以设置的文件 eureka.client.propseureka-client-env

关于java - 环境特定的 Eureka 属性未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55483811/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com