spring云服务器客户端看不到git uri的属性

idv4meu8  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(722)

我有服务器和客户端,由参考https://spring.io/guides/gs/centralized-configuration/ 但我的委托人不跑,因为

java.lang.IllegalStateException: Unable to load config data from 'http://localhost:8888'
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:128)
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:115)
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.lambda$resolve$1(ConfigDataLocationResolvers.java:115)
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:126)
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:115)
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:107)
    at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:101)
    at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:93)
    at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:81)
    at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:121)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:242)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:230)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:97)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:100)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:86)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
    at bobryakov.dmitry.ConfigurationClientApplication.main(ConfigurationClientApplication.java:9)
Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/'
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferencesForFile(StandardConfigDataLocationResolver.java:214)
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:125)
    ... 30 common frames omitted

据我所知,这是因为客户端在服务器上看不到它的文件 spring.cloud.config.server.git.uri 或者 spring.cloud.config.server.native.search-locations 或者 spring.cloud.config.server.native.searchLocations 我试过不同的符号:

file:///C:/Users/u_m167y/Desktop/config
file:///C:/Users/u_m167y/Desktop/config/
file://C:/Users/u_m167y/Desktop/config
C:/Users/u_m167y/Desktop/config
C:\\\\Users\\\\u_m167y\\\\Desktop\\\\config\\\\

但什么都不管用。我在目录中有git repo和.git和 a-bootiful-client.properties 我的客户 spring.application.name=a-bootiful-client 这里怎么了?

8cdiaqws

8cdiaqws1#

在windows上,如果文件url是带有驱动器前缀的绝对值,则需要在该文件url中添加一个“/” (for example,file:///${user.home}/config-repo) 参考spring云配置
编辑:
上面的链接有下面的列表,其中显示了在前面的示例中创建git存储库的方法:

$ cd $HOME
$ mkdir config-repo
$ cd config-repo
$ git init .
$ echo info.foo: bar > application.properties
$ git add -A .
$ git commit -m "Add application.properties"

相关问题