我刚刚从引导将我们的spring引导项目升级为v2.6.2,从spring 升级到2021.0.0。
现在,我的远程配置获取没有任何效果,而且应用程序也无法获取正确的属性文件。
主要信息o.s.c.ConfigServicePropertySourceLocator-从服务器获取配置,在:http://localhost:8080
主警告org.springframework.cloud.config.environment.Environment -无法定位PropertySource:无法提取响应:没有为响应类型o.s.c.ConfigServicePropertySourceLocator和内容类型text/html找到合适的HttpMessageConverter;charset=utf-8
主信息eu.hermes.esb.cloud.Application -没有活动配置文件集,回到默认配置文件:默认
主要信息o.s.b.c.config.ConfigDataLoader -从服务器获取配置,在:http://localhost:8080
主信息o.s.d.r.c.RepositoryConfigurationDelegate -在默认模式下引导Spring存储库。**
我们使用基于git的,该配置包含以下结构中的配置yml文件。
我尝试将这两个依赖项添加到客户端服务中,就像一些答案所建议的那样,但没有起作用。
这是我的配置服务yml:
spring.cloud.config.server:
git:
uri: https://bitbucket-prod.doa.otc.hlg.de/scm/inp-cloud/esb-spring-boot-config.git
username: foo
password: bar
force-pull: true
spring.security:
basic:
enabled: true
user:
name: inp
password: hermes我的应用程序使用以下属性运行:
-Dspring.config.import=configserver:http://inp:hermes@localhost:8080
-Dspring.cloud.config.name=esb-config-service
-Dspring.cloud.config.username=foo
-Dspring.cloud.config.username=bar
-Dspring.application.name=app-one
-Dspring.profiles.active=dev,console,gelf我们的服务是在OKD的Kubernetes提供的。但是我在windows机器上在本地复制了相同的情况,所以我不认为它是特定于环境的。
发布于 2022-02-06 16:21:48
这个问题很可能是客户端配置中的错误凭据,即用户名和密码。
根据所提供的信息很难确定。特别是,由于问题中提供的证书可能是匿名的。但是请注意,在给定的配置片段中,您设置用户名两次,而不是设置密码。此外,服务器配置的代码段没有正确缩进。客户端的属性可能应该包含
-Dspring.config.import=configserver:http://localhost:8080
-Dspring.cloud.config.username=inp
-Dspring.cloud.config.username=hermesSpring的Security自动配置并不是Spring服务器的完美匹配。问题是,当配置客户端的默认接受头被发送时,服务器会将其转发到登录页面。这就是为什么配置客户端接收到一个具有媒体类型HTML的响应体,而客户端不理解这一点。
请再次检查配置中的凭据。防止这个问题的最直接的方法是禁用配置服务器中的登录页面,如果您不需要的话。然后,您将在客户端获得一条清晰的日志消息,以查找错误的凭据。
https://stackoverflow.com/questions/70914806
复制相似问题