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

时间:2019-02-19 03:51:07

标签: java spring spring-boot spring-cloud-sleuth

我正在将应用程序升级到Spring Boot 2.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

在我收到通知该问题的WARN日志之前:

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 个答案:

答案 0 :(得分:1)

好吧,经过几个小时的努力,我取得了一些进展,现在该应用程序启动了-尽管此时问题的根本原因尚不十分清楚。 以下是我的发现:

  • 我注意到了一件奇怪的事情:如果将sender.typeweb更改为rabbit,则应用程序启动时不会出错。

  • 我还发现了与我的非常相似的Spring Boot issue report,它指向一个JDK错误。实际上,是从jdk1.8.0_25升级到jdk1.8.0_201

  • 最后,我还发现,如果我使用jdk1.8.0_25并且根本不提供sender.type,那么该应用程序也没有任何问题。

由于某种原因,在我拥有并运行的另一个应用程序中,我能够使用jdk1.8.0_25sender.type: web

如果任何人都可以快速找到解决此类问题的方法,请随时将其添加到评论中或编辑此答案。