【发布时间】:2019-10-13 16:01:31
【问题描述】:
我在服务器端有以下配置:
server:
port: 8888
spring:
profiles:
active: native
cloud:
config:
server:
native:
search-locations: "classpath:/config"
security:
user:
name: test
password: test
并在客户端进行以下配置:
spring:
cloud:
config:
fail-fast: true
profile: "${spring.profiles.active}"
uri: "${SPRING_CLOUD_CONFIG_URI:http://localhost:8888/}"
username: test
password: test
我可以使用user/pwd 作为test/test 成功地从浏览器访问属性,但是当我的客户端尝试获取它时失败并出现 401 错误:
INFO 7620 --- [5cee934b64bfd92] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
WARN 7620 --- [5cee934b64bfd92] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: 401 null
我尝试将 Spring Cloud 的日志级别设置为 DEBUG,但没有记录任何其他内容,所以我不知道为什么我会从客户端获取 401,而我可以使用相同的凭据通过浏览器成功访问属性。
我还尝试从服务器和客户端移除安全性,它运行良好,这意味着其余配置都很好。但问题是,当我应用基本安全性时,我忽略了什么以及为什么它不起作用并抛出 401?
【问题讨论】:
-
能否请您更新您的日志属性,因为根据您描述的问题很难找出原因。您需要更新实际发生的异常或错误。
-
现在是否已排序,如果是,您能否更新一下。