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

 

你可能感兴趣的:(微服务,Spring,Cloud,Config,Server,微服务配置)