Config Server模式匹配simple報錯nested exception is java.lang.IllegalStateException

測試模式匹配的配置方式

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章