【问题标题】:How to configure Spring Cloud Zipkin Server with MySQL for persistence?如何使用 MySQL 配置 Spring Cloud Zipkin Server 以实现持久性?
【发布时间】:2017-01-03 14:46:01
【问题描述】:

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

【问题讨论】:

  • 你问一个问题,一分钟之内回答???
  • stackoverflow 也有一个选项来提供像 q/a 样式这样的问题的答案。我把它贴在这里是因为我认为它对像我这样试图让它工作的人有帮助。 blog.stackoverflow.com/2011/07/…
  • 哦,好的。我预计该选项的格式会有所不同。有趣的。每天学习新东西哈哈。

标签: mysql spring-boot spring-cloud zipkin


【解决方案1】:

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

Spring Boot 版本: 1.4.0.RELEASE

Spring Cloud 版: 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/

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多