如何使用 MySQL 配置 Spring Cloud Zipkin Server 以实现持久性?

How to configure Spring Cloud Zipkin Server with MySQL for persistence?

Spring Boot/Cloud Zipkin 服务器(可能是 Zipkin Stream 服务器)使用 MySQL 持久化跟踪数据需要哪些确切的依赖关系和 application.yml 配置?

官方文档很有帮助,但我认为它没有明确包含所有依赖项(至少到目前为止)。我不得不对示例进行一些额外的研究,以将所有必需的依赖项和配置放在一起。我想分享它,因为我相信它可能对其他人有帮助。

Spring 引导版本: 1.4.0.RELEASE

Spring云版:Brixton.SR4

POM:

    ...
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-server</artifactId>
    </dependency>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-storage-mysql</artifactId>
    </dependency>

    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-ui</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
   ...
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Brixton.SR4</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

Java:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import zipkin.server.EnableZipkinServer;

@SpringBootApplication
@EnableZipkinServer
public class ZipkinServerApplication {

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

application.yml:

spring:
  datasource:
    schema: classpath:/mysql.sql
    url: jdbc:mysql://localhost:3306/zipkin?autoReconnect=true
    username: root
    password: admin
    driver-class-name: com.mysql.jdbc.Driver
    initialize: true
    continue-on-error: true
  sleuth:
    enabled: false
zipkin:
  storage:
    type: mysql

参考文献:

https://cloud.spring.io/spring-cloud-sleuth/