spring-boot2.1.9.RELEASE+zipkin2.12.9搭建zipkin-server

spring-boot当前最新版本2.2.1.RELEASE
zipkin当前最新版本2.12.9

spring-boot2.0后官方不推荐自定义zipkin-server 并提供了可执行jar 下载地址 选择exec.jar结尾的jar下载即可 java -jar zipkin-server-2.12.9-exec.jar

但是依然希望可在cloud项目中管理 经过一些努力 本文可在spring-boot2.1.9.RELEAS+zipkin2.12.9下运行 代码如下


pom.xml

<parent>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-parentartifactId>
    <version>2.1.9.RELEASEversion>
    <relativePath/> 
parent>

<groupId>com.examplegroupId>
<artifactId>zipkin-serverartifactId>
<version>1.0version>
<name>zipkin-servername>
<description>this-zipkin-serverdescription>

<properties>
    <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
    <java.version>1.8java.version>
    <spring-cloud.version>Hoxton.M3spring-cloud.version>
    <zipkin.version>2.12.9zipkin.version>
    <mysql-connector.version>8.0.14mysql-connector.version>
properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-webartifactId>
    dependency>

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

    <dependency>
        <groupId>io.zipkin.javagroupId>
        <artifactId>zipkin-autoconfigure-uiartifactId>
        <version>${zipkin.version}version>
    dependency>
dependencies>

启动类

package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import zipkin2.server.internal.EnableZipkinServer;

@EnableZipkinServer
@SpringBootApplication
public class ZipkinServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ZipkinServerApplication.class, args);
    }

}

application.yml

server:
#  port: 9411
  compression:
    # 是否开启压缩 默认false
    enabled: true
spring:
  application:
    name: zipkin-server
  main:
    # 让应用以非web服务方式启动 server.port配置将会失效
    web-application-type: none

代码地址 https://github.com/tothis/spring-cloud-learn/tree/master/zipkin-server

你可能感兴趣的:(#,spring-cloud)