【发布时间】:2022-01-11 19:48:18
【问题描述】:
我按照this 和this 示例在kube 中运行spring boot 应用程序并重新加载配置映射。当我设置值时,一切正常。但是当我想从地图中设置 null 或删除值时,什么也没有发生
例如我的初始化配置映射是:
apiVersion: v1
kind: ConfigMap
metadata:
name: my-app
data:
application.yaml: |-
config:
testicek: stringvalue123
inticek: 123
但是当我将其更改为 a 并应用配置映射时:
apiVersion: v1
kind: ConfigMap
metadata:
name: my-app
data:
application.yaml: |-
config:
testicek: null
inticek: null
然后 testicek what is String 包含空字符串 not null 并且 inticek what is Integer 甚至没有刷新并且仍然包含旧值。任何提示如何解决这个问题?
更新
所以我找到了为什么 null 被解析为空字符串here。那么4年后仍然没有钩点如何改变这种行为?更糟糕的是,当我想将 Integer 更改为 null 时什么也没有发生,因为我猜 Integer 不能为空,所以在 configMap 更改后甚至不会调用我的属性的 setter
【问题讨论】:
-
在您的问题中,您提到“testicek 什么是 String 包含空字符串而不是 null 并且 inticek 什么是 Integer 甚至没有刷新并且仍然包含旧值”。这与 configmap 或您的 Spring Boot 应用程序有关吗?由于应用更改的 configmap 后,
testicek和inticek应该更改。您能否在应用更改后为kubectl describe configmap my-app添加输出? -
是的,kubectl 中的配置映射的两个属性都为 null,但在我的 Spring Boot 应用程序中 inticek 仍然是旧值
标签: java spring-boot kubernetes