測試模式匹配的配置方式
spring:
cloud:
config:
server:
git:
# 模式匹配:帶有通配符的{application}/{profile}名稱的列表,如果不匹配任何模式,它將使用spring.cloud.config.server.git.uri
uri: https://github.com/xxx/spring-cloud-config-repo # 配置默認的Git倉庫的地址
# 配置帶有通配符的{application}/{profile}名稱的列表
repos:
# 只匹配所有配置文件中名爲simple的應用程序
simple: https://github.com/xxxx/special-spring-cloud-config-repo
其他模式我配置測試都沒有問題,就是這個simple模式,url配置的string報轉換類型錯誤。不知爲何?
從報錯看需要key,value的SshUriProperties格式
Property: spring.cloud.config.server.git.repos[simple]
Value: https://github.com/xxxx/simple/spring-cloud-config-repo
Reason: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.cloud.config.server.ssh.SshUriProperties$SshUriNestedRepoProperties' for property 'repos[simple]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'org.springframework.cloud.config.server.ssh.SshUriPropertiesDescription:
Binding to target org.springframework.cloud.config.server.ssh.SshUriProperties(uri=https://github.com/xxxx/spring-cloud-config-repo hostKeyAlgorithm=null, hostKey=null, privateKey=null, ignoreLocalSshSettings=false, knownHostsFile=null, preferredAuthentications=null, strictHostKeyChecking=true,){repos={special=org.springframework.cloud.config.server.ssh.SshUriProperties(uri=https://github.com/xxxx/spring-cloud-config-repo hostKeyAlgorithm=null, hostKey=null, privateKey=null, ignoreLocalSshSettings=false, knownHostsFile=null, preferredAuthentications=null, strictHostKeyChecking=true,), local=org.springframework.cloud.config.server.ssh.SshUriProperties(uri=file:D:/WorkSpace/spring-cloud-config-repo hostKeyAlgorithm=null, hostKey=null, privateKey=null, ignoreLocalSshSettings=false, knownHostsFile=null, preferredAuthentications=null, strictHostKeyChecking=true,)}} failed:
Property: spring.cloud.config.server.git.repos[simple]
Value: https://github.com/xxxx/simple/spring-cloud-config-repo
Reason: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.cloud.config.server.ssh.SshUriProperties$SshUriNestedRepoProperties' for property 'repos[simple]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'org.springframework.cloud.config.server.ssh.SshUriProperties$SshUriNestedRepoProperties' for property 'repos[simple]': no matching editors or conversion strategy found$SshUriNestedRepoProperties' for property 'repos[simple]': no matching editors or conversion strategy found
修改配置,增加uri的key,即可正常啓動
spring:
cloud:
config:
server:
git:
# 模式匹配:帶有通配符的{application}/{profile}名稱的列表,如果不匹配任何模式,它將使用spring.cloud.config.server.git.uri
uri: https://github.com/xxxx/spring-cloud-config-repo # 配置默認的Git倉庫的地址
# 配置帶有通配符的{application}/{profile}名稱的列表
repos:
# 只匹配所有配置文件中名爲simple的應用程序
simple:
uri:https://github.com/xxxx/special-spring-cloud-config-repo