Spring Cloud配置服务器无法读取属性文件。

huangapple go评论79阅读模式
英文:

Spring cloud config server not able to read property file

问题

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

发生意外错误(类型=内部服务器错误,状态=500)。
无法为config=应用程序配置构建上下文profile=default标签=includeOrigin=false;嵌套异常是java.lang.IllegalStateException:ConfigFileApplicationListener[org.springframework.boot.context.config.ConfigFileApplicationListener]已弃用,只能用作EnvironmentPostProcessor
org.springframework.cloud.config.server.environment.FailedToConstructEnvironmentException:无法为config=应用程序配置构建上下文profile=default标签=includeOrigin=false;嵌套异常是java.lang.IllegalStateException:ConfigFileApplicationListener[org.springframework.boot.context.config.ConfigFileApplicationListener]已弃用,只能用作EnvironmentPostProcessor
    在org.springframework.cloud.config.server.environment.NativeEnvironmentRepository.findOne(NativeEnvironmentRepository.java:161)中
    在org.springframework.cloud.config.server.environment.AbstractScmEnvironmentRepository.findOne(AbstractScmEnvironmentRepository.java:59)中
    在org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.findOne(MultipleJGitEnvironmentRepository.java:187)中
    在org.springframework.cloud.config.server.environment.CompositeEnvironmentRepository.findOne(CompositeEnvironmentRepository.java:58)中
    在org.springframework.cloud.config.server.environment.EnvironmentEncryptorEnvironmentRepository.findOne(EnvironmentEncryptorEnvironmentRepository.java:61)中
    在org.springframework.cloud.config.server.environment.EnvironmentController.getEnvironment(EnvironmentController.java:136)中
    在org.springframework.cloud.config.server.environment.EnvironmentController.defaultLabel(EnvironmentController.java:108)中
    在sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)中
    在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

请告诉我我做错了什么。

英文:

My Spring cloud config server is throwing below error when trying to access the property file content using 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)

My application.properties in config server looks like this

spring.cloud.config.server.git.uri=/Users/joe/MyProgs/Java/spring-ws/config and I even tried with this spring.cloud.config.server.git.uri=${HOME}/MyProgs/Java/spring-ws/config

Content of the property file in the local git repository is

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

Please let me know what I am doing wrong.

答案1

得分: 2

这个弃用消息似乎是在几周前添加的,在这个问题中。这些更改甚至还没有发布(标记为未来版本的Spring Boot 2.4.0-M2中发布)。你使用的Spring Boot版本是多少?我猜想你的构建配置中有一个SNAPSHOT依赖项。

英文:

It looks like this deprecation message was added just a couple of weeks ago in this issue. These changes are not even released yet (marked for release in a future milestone version of Spring Boot 2.4.0-M2).

What version of Spring Boot are you using? I suppose you have a SNAPSHOT dependency somewhere in your build configuration.

huangapple
  • 本文由 发表于 2020年8月5日 19:28:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/63264220.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定