首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >服务器不选择更改

服务器不选择更改
EN

Stack Overflow用户
提问于 2020-07-12 13:27:35
回答 1查看 2.2K关注 0票数 2

我正在尝试使用本地文件系统来设置spring配置云。

下面是我在云服务器上的配置。

代码语言:javascript
复制
server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=classpath:/

客户端应用程序上的Bootstrap.properties如下所示

代码语言:javascript
复制
spring.application.name=hello-world
spring.cloud.config.uri=http://localhost:8888
management.endpoints.web.exposure.include=*

我还在类路径上为带有属性test: Hello World的hello-world spring引导应用程序创建了hello-world.yml

按照以下步骤使用配置服务器。

  • 步骤1:更新配置文件并启动云配置服务器。能够看到配置http://localhost:8888/hello-world/default

  • 步骤2:启动客户端应用程序hello-world,客户端应用程序可以从云配置服务器读取test属性文件。

  • 步骤3:通过更新hello-world.yaml上的test: Good Bye来更改配置。

此时,如果我检查http://localhost:8888/hello-world/default,它仍然显示旧值.

  • 步骤4:在客户端应用程序上运行/actuator/refresh。但是它不会检测到配置服务器上的任何更改。

只有当我重新启动云配置服务器时,新的更改才会得到反映。是否存在导致云配置服务器无法侦听更改的配置问题?

我可以在云配置应用程序上看到o.s.cloud.commons.util.InetUtils : Cannot determine local hostname信息日志。

EN

回答 1

Stack Overflow用户

发布于 2020-09-02 08:51:49

首先,我遵循了你所遵循的相同的步骤,得到了同样的问题,在对这件事进行了近一天的搜索和研究之后,我发现了以下内容,

  1. 我们不应该为spring.cloud.config.server.native.searchLocations使用classpath:/<whatever>,因为当我们使用它并构建项目并运行位置时,这个位置引用了生成的.jar文件中的目录,所以我们无法在运行时更新它。

要确认这一点,可以停止配置服务器,打开.jar存档并删除hello-world.yml文件,然后尝试http://localhost:8888/hello-world/default,您将得到默认的空响应。

  1. ,所以我们必须为spring.cloud.config.server.native.searchLocations使用其他位置,要么使用完整的目录路径,要么只使用来自应用程序运行位置

的目录。

示例

窗口中的完整路径的file:///full-path

  • 使用spring.cloud.config.server.native.searchLocations: file:///E:\configs

  1. 只用于一个目录(如果从运行,则将搜索项目根目录,如果运行jar,则搜索目标目录或jar位置spring.cloud.config.server.native.searchLocations: configsspring.cloud.config.server.native.searchLocations: configs)。

我们也可以配置多个位置,如下所示,spring.cloud.config.server.native.searchLocations: file:///E:\configs, configs

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62861682

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档