我正在尝试使用本地文件系统来设置spring配置云。
下面是我在云服务器上的配置。
server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=classpath:/客户端应用程序上的Bootstrap.properties如下所示
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
按照以下步骤使用配置服务器。
http://localhost:8888/hello-world/defaulthello-world,客户端应用程序可以从云配置服务器读取test属性文件。test: Good Bye来更改配置。此时,如果我检查http://localhost:8888/hello-world/default,它仍然显示旧值.
/actuator/refresh。但是它不会检测到配置服务器上的任何更改。只有当我重新启动云配置服务器时,新的更改才会得到反映。是否存在导致云配置服务器无法侦听更改的配置问题?
我可以在云配置应用程序上看到o.s.cloud.commons.util.InetUtils : Cannot determine local hostname信息日志。
发布于 2020-09-02 08:51:49
首先,我遵循了你所遵循的相同的步骤,得到了同样的问题,在对这件事进行了近一天的搜索和研究之后,我发现了以下内容,
spring.cloud.config.server.native.searchLocations使用classpath:/<whatever>,因为当我们使用它并构建项目并运行位置时,这个位置引用了生成的.jar文件中的目录,所以我们无法在运行时更新它。要确认这一点,可以停止配置服务器,打开.jar存档并删除hello-world.yml文件,然后尝试http://localhost:8888/hello-world/default,您将得到默认的空响应。
spring.cloud.config.server.native.searchLocations使用其他位置,要么使用完整的目录路径,要么只使用来自应用程序运行位置的目录。
示例
窗口中的完整路径的file:///full-path
spring.cloud.config.server.native.searchLocations: file:///E:\configsspring.cloud.config.server.native.searchLocations: configsspring.cloud.config.server.native.searchLocations: configs)。我们也可以配置多个位置,如下所示,spring.cloud.config.server.native.searchLocations: file:///E:\configs, configs
https://stackoverflow.com/questions/62861682
复制相似问题