admin管理员组文章数量:1394593
I have a Spring Boot + Spring Cloud application that I'd like to build as a native image for faster startup time and smaller image size. I understand that Spring Cloud is not yet providing official support for native images, so I'm manually registering hints for reflection using Spring's RuntimeHintsRegistrar
during AOT processing.
Now I'm able to build a native image with gradle bootBuildImage
, but when I deploy the image to Kubernetes it fails with this error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method kubernetesPodUtils in .springframework.cloud.kubernetes.fabric8.Fabric8AutoConfiguration required a single bean, but 2 were fou
- kubernetesClient: defined in unknown location
- configKubernetesClient: a programmatically registered singleton
The kubernetesClient
bean is provided in Fabric8AutoConfiguration
, while configKubernetesClient
is registered programmatically in Fabric8ConfigDataLocationResolver
.
This does not happen if I deploy a non-native image of the same exact application, so I guess it's the AOT processing that is missing something.
The app depends on spring-cloud-starter-kubernetes-fabric8-config
and has the following properties set:
spring.config.import=kubernetes:
spring.cloud.kubernetes.config.reload.enabled=true
Why does this happen in the native image? Is the AOT processing missing some hint that I can register manually? I know I can workaround this by providing yet another KubernetesClient
bean in my app code and annotate it with @Primary
, but I'd prefer to use the one provided by Spring Cloud and not override it.
本文标签: spring bootWhy do I get two KubernetesClient beans only when running a native imageStack Overflow
版权声明:本文标题:spring boot - Why do I get two KubernetesClient beans only when running a native image? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744096515a2590382.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论