Spring boot 无法从Kubernetese配置映射读取int值

Spring boot 无法从Kubernetese配置映射读取int值,spring-boot,kubernetes,kubectl,configmap,Spring Boot,Kubernetes,Kubectl,Configmap,我正在尝试在kubernetese上部署springboot应用程序。我已将所有环境变量存储在配置映射中,并尝试从中读取值。我们需要在某些属性中读取int值 在我们的代码中,它看起来像这样: application.properties: TOKEN_RETRY_COUNT=3 TOKEN_RETRY_COUNT=${STARGATE_TOKEN_RETRY_LIMIT} Failed to convert value of type 'java.lang.String' to requir

我正在尝试在kubernetese上部署springboot应用程序。我已将所有环境变量存储在配置映射中,并尝试从中读取值。我们需要在某些属性中读取int值

在我们的代码中,它看起来像这样:

application.properties:

TOKEN_RETRY_COUNT=3
TOKEN_RETRY_COUNT=${STARGATE_TOKEN_RETRY_LIMIT}
Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "STARGATE_TOKEN_RETRY_LIMIT"
由于必须从ConfigMap中读取,我们已更新了application.properties,如下所述:

更新application.properties:

TOKEN_RETRY_COUNT=3
TOKEN_RETRY_COUNT=${STARGATE_TOKEN_RETRY_LIMIT}
Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "STARGATE_TOKEN_RETRY_LIMIT"
配置映射

在配置映射中配置的值如下所示。我不得不加上双引号,因为没有任何引号是不允许的

"STARGATE_TOKEN_RETRY_LIMIT": "3",
现在,当我在kubernetese上部署后尝试读取这些值时,我得到以下错误:

对于星际之门\u令牌\u重试\u限制:

TOKEN_RETRY_COUNT=3
TOKEN_RETRY_COUNT=${STARGATE_TOKEN_RETRY_LIMIT}
Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "STARGATE_TOKEN_RETRY_LIMIT"
目前,我已经更新了代码,将该值作为字符串,然后将其解析为int,但这不是理想的方法。应该有一些标准的方法来选择不同的类型


如果我们不能处理配置映射中的不同类型,那么在kubernetese上为Springboot应用程序传递不同应用程序属性的理想方法是什么?

我认为问题与属性值(3)被指定为字符串(“3”)无关。如果仔细阅读错误消息,您会发现
NumberFormatException
是由于试图将STARGATE\u TOKEN\u RETRY\u LIMIT(字面)解析为an
int
引起的。配置映射传递到应用程序/容器的方式可能有问题