简体   繁体   English

Spring yaml 属性 java.util.LinkedHashMap 无法转换为 java.lang.String

[英]Spring yaml property java.util.LinkedHashMap cannot be cast to java.lang.String

I try to pass Docker env variable in my Spring boot application.yml like this:我尝试在我的 Spring boot application.yml 中传递 Docker 环境变量,如下所示:

  security:
    saml2:
      relyingparty:
        registration:
          my-saml:
            signing:
              credentials:
                - private-key-location: classpath:HARD_PATH_TO_KEY
                  certificate-location: classpath:HARD_PATH_TO_CERT
            identityprovider:
              verification.credentials:
                - certificate-location: classpath:HARD_PATH_TO_CERT
              entity-id: MY_ID
              singlesignon:
                url: {{saml.ip.singlesignon.url}}
                sign-request: true

But when I use env variable to但是当我使用环境变量来

            - private-key-location: {{saml.ip.private.key}}
              certificate-location: {{saml.ip.certif.emp}}

and

          verification.credentials:
            - certificate-location: {{saml.ip.certif2.emp}}

I got this error:我收到此错误:

java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.lang.String
    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
    at org.springframework.beans.factory.config.YamlProcessor.buildFlattenedMap(YamlProcessor.java:309)
    at org.springframework.beans.factory.config.YamlProcessor.lambda$buildFlattenedMap$1(YamlProcessor.java:325)
    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
    at org.springframework.beans.factory.config.YamlProcessor.buildFlattenedMap(YamlProcessor.java:309)
    at org.springframework.beans.factory.config.YamlProcessor.lambda$buildFlattenedMap$1(YamlProcessor.java:325)
    at java.util.Collections$SingletonMap.forEach(Collections.java:4910)

 

Any idea任何的想法

Try to remove the '-' at the beginning of lines尝试删除行首的“-”

          private-key-location: {{saml.ip.private.key}}
          certificate-location: {{saml.ip.certif.emp}}
          ...
          certificate-location: {{saml.ip.certif2.emp}}

If you want 2 separate Strings, or credentials is a Map, I think it should be:如果你想要 2 个单独的字符串,或者credentials是一个 Map,我认为它应该是:

             credentials:
                 private-key-location: {{saml.ip.private.key}}
                 certificate-location: {{saml.ip.certif.emp}}

If you want an array, I think it should be:如果你想要一个数组,我认为它应该是:

             credentials:
                 - private-key-location: {{saml.ip.private.key}}
                 - certificate-location: {{saml.ip.certif.emp}}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 class java.util.LinkedHashMap cannot be cast to class java.lang.String (java.util.LinkedHashMap and java.lang.String - class java.util.LinkedHashMap cannot be cast to class java.lang.String (java.util.LinkedHashMap and java.lang.String 如何修复 class java.util.LinkedHashMap 无法转换为 class Z93F725A07428BString.3321C886F46D4 错误。 - how to fix class java.util.LinkedHashMap cannot be cast to class java.lang.String error java.lang.ClassCastException:无法强制转换java.util.LinkedHashMap - java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast Java Spring rest java.lang.ClassCastException:java.util.LinkedHashMap 不能转换为 Cuestionario - Java Spring rest java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to Cuestionario spring-data-redis @Cacheable java.lang.ClassCastException: java.util.LinkedHashMap 无法转换为 MyObject - Spring-data-redis @Cacheable java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to MyObject 找不到能够从类型 [java.util.LinkedHashMap 进行转换的转换器<?, ?> ] 输入 [java.lang.String] - Spring 配置服务器 - No converter found capable of converting from type [java.util.LinkedHashMap<?, ?>] to type [java.lang.String] - Spring config server 无法反序列化 `java.util.LinkedHashMap 类型的值<java.lang.string,java.lang.string> ` 来自 Array 或什么是我的字段的正确类型</java.lang.string,java.lang.string> - Cannot deserialize value of type `java.util.LinkedHashMap<java.lang.String,java.lang.String>` from Array or what would be a correct type of my field Spring websocket @messagemapping反序列化问题java.lang.ClassCastException:java.util.LinkedHashMap无法强制转换 - Spring websocket @messagemapping de-serialization issue java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast java.lang.ClassCastException:java.util.LinkedHashMap 无法转换为 java.time.LocalDateTime - java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.time.LocalDateTime java.lang.ClassCastException:无法将java.util.LinkedHashMap强制转换为com。****。db。***** - java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.****.db.*****
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM