代码之家  ›  专栏  ›  技术社区  ›  Vincent F

无法在Spring Boot 2中绑定Zipkin枚举

  •  0
  • Vincent F  · 技术社区  · 6 年前

    我正在将一个应用程序升级到SpringBoot2.1.3(从1.5.x开始),在启动时我面临一个问题。下面的块无法正确绑定:

      spring:
        zipkin:
          enabled: true
          base-url: http://myZipkinServer
          sender:
            type: web
    

    我得到这个错误:

    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    Failed to bind properties under 'spring.zipkin.sender.type' to org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties$SenderType:
    
    Property: spring.zipkin.sender.type
    Value: web
    Origin: class path resource [application.yml]:68:13
    Reason: 0
    
    Action:
    
    Update your application's configuration
    

    在我收到警告日志宣布问题之前:

    Exception encountered during context initialization - cancelling refresh attempt: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.zipkin.sender-org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties': Could not bind properties to 'ZipkinSenderProperties' : prefix=spring.zipkin.sender, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.zipkin.sender.type' to org.springframework.cloud.sleuth.zipkin2.sender.ZipkinSenderProperties$SenderType
    

    我试图在调试中跟进,最终我深入到了Spring Boot的内部 在里面 org.springframework.boot.context.properties.bind.Binder . 我有一个类似的应用程序,它的版本或多或少都是相同的,而且运行得很好。我试图找出不同之处,比较执行流,但没有发现任何明显的差异。

    在IntelliJ中,我得到了自动完成,因此我知道我的yaml格式正确:“web”值是向我提出的。

    你知道如何调查这类问题吗?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Vincent F    6 年前

    好吧,经过几个小时的努力,我取得了一些进展,现在应用程序启动了——尽管目前我还不完全清楚问题的根本原因。 以下是我的调查结果:

    • 我注意到一件奇怪的事:如果我改变 sender.type 从…起 web rabbit ,则应用程序将无错误地启动。

    • 我还发现了这只弹簧靴 issue report ,与我的非常相似,这是针对JDK错误的。事实上,从 jdk1.8.0_25 jdk1.8.0_201 .

    • 最后,我还发现如果我使用 jdk1。8.0_25 而且没有提供 发件人。类型 在所有,然后应用程序也开始没有问题。

    出于某种原因,在我拥有的另一个应用程序中,我可以使用它 jdk1。8.0_25 sender.type: web

    如果有人有一种方法可以快速解决此类问题,请毫不犹豫地将其添加到评论中或编辑此答案。