【问题标题】:Spring cloud config server not able to read property fileSpring Cloud 配置服务器无法读取属性文件
【发布时间】:2020-11-25 13:45:30
【问题描述】:

我的 Spring 云配置服务器在尝试使用 http://localhost:8080/application/default 访问属性文件内容时抛出以下错误

There was an unexpected error (type=Internal Server Error, status=500).
Could not construct context for config=application profile=default label= includeOrigin=false; nested exception is java.lang.IllegalStateException: ConfigFileApplicationListener [org.springframework.boot.context.config.ConfigFileApplicationListener] is deprecated and can only be used as an EnvironmentPostProcessor
org.springframework.cloud.config.server.environment.FailedToConstructEnvironmentException: Could not construct context for config=application profile=default label= includeOrigin=false; nested exception is java.lang.IllegalStateException: ConfigFileApplicationListener [org.springframework.boot.context.config.ConfigFileApplicationListener] is deprecated and can only be used as an EnvironmentPostProcessor
    at org.springframework.cloud.config.server.environment.NativeEnvironmentRepository.findOne(NativeEnvironmentRepository.java:161)
    at org.springframework.cloud.config.server.environment.AbstractScmEnvironmentRepository.findOne(AbstractScmEnvironmentRepository.java:59)
    at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.findOne(MultipleJGitEnvironmentRepository.java:187)
    at org.springframework.cloud.config.server.environment.CompositeEnvironmentRepository.findOne(CompositeEnvironmentRepository.java:58)
    at org.springframework.cloud.config.server.environment.EnvironmentEncryptorEnvironmentRepository.findOne(EnvironmentEncryptorEnvironmentRepository.java:61)
    at org.springframework.cloud.config.server.environment.EnvironmentController.getEnvironment(EnvironmentController.java:136)
    at org.springframework.cloud.config.server.environment.EnvironmentController.defaultLabel(EnvironmentController.java:108)
    at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

我在配置服务器中的 application.properties 看起来像这样

spring.cloud.config.server.git.uri=/Users/joe/MyProgs/Java/spring-ws/config 我什至尝试过这个spring.cloud.config.server.git.uri=${HOME}/MyProgs/Java/spring-ws/config

本地git仓库中属性文件的内容是

martin:
    name: Martin D'vloper
    job: Developer
    skill: Elite

请让我知道我做错了什么。

【问题讨论】:

    标签: java spring-boot spring-cloud-config


    【解决方案1】:

    这条弃用消息似乎是几周前在this issue 中添加的。这些更改甚至还没有发布(标记为在 Spring Boot 2.4.0-M2 的未来里程碑版本中发布)。

    您使用的是哪个版本的 Spring Boot?我想你的构建配置中有一个 SNAPSHOT 依赖项。

    【讨论】:

    • 我使用的是 2.4.0(SNAPSHOT)。现在我已将其更改为 2.1.16 RELEASE 版本,并且工作正常。谢谢
    猜你喜欢
    • 2015-01-03
    • 2015-06-18
    • 2018-08-24
    • 2021-03-29
    • 2021-06-23
    • 2016-02-07
    • 2020-06-09
    • 1970-01-01
    • 2022-10-05
    相关资源
    最近更新 更多