Spring boot Spring云配置验证问题
我正在尝试为我的一个项目配置SpringCloud配置。它以前工作得相当好。然而,使用最新版本的Spring,我在尝试启用身份验证时遇到了麻烦。这是我看到的日志Spring boot Spring云配置验证问题,spring-boot,spring-cloud,Spring Boot,Spring Cloud,我正在尝试为我的一个项目配置SpringCloud配置。它以前工作得相当好。然而,使用最新版本的Spring,我在尝试启用身份验证时遇到了麻烦。这是我看到的日志 INFO Fetching config from server at : http://localhost:8888 WARN Could not locate PropertySource: Could not extract response: no suitable HttpMessageConverter found fo
INFO Fetching config from server at : http://localhost:8888
WARN Could not locate PropertySource: Could not extract response: no suitable HttpMessageConverter found for response type [class org.springframework.cloud.config.environment.Environment] and content type [text/html;charset=UTF-8]
INFO The following profiles are active: development
有人面对过这个问题吗?如果没有身份验证,SpringCloudConfig客户端可以正常工作,但如果启用了基本身份验证,则相同的代码无法工作
Spring云配置服务器应用程序。属性:
spring.application.name=my-config
server.port=8888
spring.cloud.config.server.git.uri=file:///repo/my-config
spring.security.user.name=root
spring.security.user.password=root
spring.application.name=my-service
spring.profiles.active=development
spring.cloud.config.uri=http://localhost:8888
management.endpoints.web.exposure.include=*
spring.cloud.config.username=root
spring.cloud.config.password=root
Spring云配置客户端Bootstrap.yml:
spring.application.name=my-config
server.port=8888
spring.cloud.config.server.git.uri=file:///repo/my-config
spring.security.user.name=root
spring.security.user.password=root
spring.application.name=my-service
spring.profiles.active=development
spring.cloud.config.uri=http://localhost:8888
management.endpoints.web.exposure.include=*
spring.cloud.config.username=root
spring.cloud.config.password=root
我的配置服务器和服务项目对Spring Boot和Spring Cloud使用相同的版本属性
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
<spring-cloud-config.version>2.2.0.RELEASE</spring-cloud-config.version>
奇怪的是,记录器输出为空,这意味着没有活动的配置文件。因此很明显,此bootstrap.properties配置被忽略。为了绕过这个问题,我在服务启动中添加了这个JVM参数
-Dspring.profiles.active=development -Dspring.application.name=my-service
这有效地解决了配置文件未被检测到的问题。但是,我仍然不清楚为什么我的bootstrap.properties中忽略了spring.profiles.active=开发配置。您需要在“配置服务器”应用程序中提供
本机
配置文件,而将开发
配置文件留给客户端。以下配置工作:
配置服务器
server:
port: 9001
servlet.context-path: /my-config-server
spring:
application.name: my-config-server
profiles:
active: native
main:
banner-mode: "OFF"
cloud:
config:
uri: http://localhost:9001/my-config-server
fail-fast: true
username: root
password: root
spring:
application.name: user-api
profiles:
active: development
main:
#banner-mode: "OFF"
cloud:
config:
uri: http://localhost:9001/my-config-server
fail-fast: true
username: root
password: root
spring:
profiles: native
cloud:
config:
server:
native:
searchLocations: file:<path-to-files>
git:
clone-on-start: false # Only clone(true) on-demand
配置服务器上的spring安全配置是什么?我在帖子中列出了我的配置服务器application.properties文件。我需要列出一些具体的东西。这不是spring安全配置。您是否在java代码中进行任何自定义spring安全配置?请尝试将服务器配置文件更改为本机配置文件,如果这样做有效,您的git uri或身份验证可能会出现问题same@spencergibb谢谢你的澄清,我想我应该更仔细地阅读你的评论。我的配置或服务项目中没有定义任何单独的Spring安全文件。我没有考虑定义它。我尝试了配置服务器配置,并在控制台上观察到以下行“使用生成的安全密码:8e9fc620-0bf8-4a5c-8e3b-c135c84d1af4”。在此之后,我尝试使用URL“”登录配置服务器,但登录失败。不确定哪里出错。请尝试将服务器/客户端中的“spring.security.user.name=root”和“spring.security.user.password=root”替换为“spring.cloud.config.username”和“spring.cloud.config.password”。请参阅“让我知道您是否已解决此问题”,否则我们可以在客户端进一步查看,因为无法解决属性。怎么了?