Zipkin Server 无法启动的问题

加入 Zipkin Server

由于需要收集 Spring Cloud 系统的跟踪信息,以便及时地发现系统中出现的延迟升高问题并找出系统性能瓶颈的根源,所以在 Spring Cloud 项目中创建 Zipkin Server。
在 zipkin-server 模块中引入了如下依赖:

<dependency>
     <groupId>io.zipkin.javagroupId>
     <artifactId>zipkin-serverartifactId>
     <version>2.12.9version>
 dependency>
 <dependency>
     <groupId>io.zipkin.javagroupId>
     <artifactId>zipkin-autoconfigure-uiartifactId>
     <version>2.12.9version>
 dependency>

Multiple SLF4J Bindings

在 Spring Boot 启动类加上 @EnableZipkinServer 注解,启动项目,控制台报错:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/jake/respository/org/apache/logging/log4j/log4j-slf4j-impl/2.11.2/log4j-slf4j-impl-2.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/jake/respository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.StackOverflowError
	at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:108)

谷歌搜索了一下,需要排除 zipkin-server 中依赖的 SLF4j

<dependency>
    <groupId>io.zipkin.javagroupId>
    <artifactId>zipkin-serverartifactId>
    <version>2.12.9version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.logging.log4jgroupId>
            <artifactId>log4j-slf4j-implartifactId>
        exclusion>
    exclusions>
dependency>

armeriaServer 版本冲突

再次启动项目,报错:

Caused by: java.lang.NullPointerException: null
	at zipkin2.autoconfigure.ui.ZipkinUiAutoConfiguration.lambda$uiServerConfigurator$0(ZipkinUiAutoConfiguration.java:179) ~[zipkin-autoconfigure-ui-2.12.9.jar:na]
	at com.linecorp.armeria.spring.ArmeriaAutoConfiguration.lambda$armeriaServer$0(ArmeriaAutoConfiguration.java:111) ~[armeria-spring-boot-autoconfigure-0.83.0.jar:na]
	at java.util.ArrayList.forEach(ArrayList.java:1257) ~[na:1.8.0_211]
	at com.linecorp.armeria.spring.ArmeriaAutoConfiguration.lambda$armeriaServer$1(ArmeriaAutoConfiguration.java:110) ~[armeria-spring-boot-autoconfigure-0.83.0.jar:na]
	at java.util.Optional.ifPresent(Optional.java:159) ~[na:1.8.0_211]
	at com.linecorp.armeria.spring.ArmeriaAutoConfiguration.armeriaServer(ArmeriaAutoConfiguration.java:109) ~[armeria-spring-boot-autoconfigure-0.83.0.jar:na]
	at com.linecorp.armeria.spring.ArmeriaAutoConfiguration$$EnhancerBySpringCGLIB$$2d84b2a7.CGLIB$armeriaServer$0(<generated>) ~[armeria-spring-boot-autoconfigure-0.83.0.jar:na]
	at com.linecorp.armeria.spring.ArmeriaAutoConfiguration$$EnhancerBySpringCGLIB$$2d84b2a7$$FastClassBySpringCGLIB$$4c907816.invoke(<generated>) ~[armeria-spring-boot-autoconfigure-0.83.0.jar:na]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at com.linecorp.armeria.spring.ArmeriaAutoConfiguration$$EnhancerBySpringCGLIB$$2d84b2a7.armeriaServer(<generated>) ~[armeria-spring-boot-autoconfigure-0.83.0.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_211]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_211]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_211]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	... 20 common frames omitted

根据搜索结果,得到
错误原因:
Zipkin最新版本为 2.12.9,从 2.12.6 开始有一个较大的更新:迁移使用了 Armeria HTTP 引擎,存在版本冲突。
解决方法:
将版本降低到 2.12.3 就可以正常启动了。
于是把 Zipkin 的依赖版本修改为 2.12.3:

<dependency>
    <groupId>io.zipkin.javagroupId>
    <artifactId>zipkin-serverartifactId>
    <version>2.12.3version>
    <exclusions>
        <exclusion>
            <groupId>org.apache.logging.log4jgroupId>
            <artifactId>log4j-slf4j-implartifactId>
        exclusion>
    exclusions>
dependency>
<dependency>
    <groupId>io.zipkin.javagroupId>
    <artifactId>zipkin-autoconfigure-uiartifactId>
    <version>2.12.3version>
dependency>

访问 Zipkin UI

再次启动,成功!访问 localhost:9411
Zipkin Server 无法启动的问题_第1张图片

你可能感兴趣的:(Spring,Cloud,Zipkin)