一、maven包依赖
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.pkfare
zipkin
1.0.0
jar
UTF-8
org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
org.springframework.cloud
spring-cloud-dependencies
Dalston.SR5
pom
import
org.springframework.boot
spring-boot-starter
io.zipkin.java
zipkin-server
io.zipkin.java
zipkin-autoconfigure-ui
io.zipkin.java
zipkin-storage-mysql
2.4.9
org.springframework.boot
spring-boot-starter-jdbc
mysql
mysql-connector-java
src/main/java
src/main/resources
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-compiler-plugin
1.8
1.8
UTF-8
配置文件如下,zipkin.storage.type用于指定存储类型,默认为mem,内存存储,在类ZipkinServerConfiguration中
spring.application.name=zipkin-server
server.port=11008
spring.datasource.url=jdbc:mysql://localhost:3306/zipkin?autoReconnect=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
zipkin.storage.type=mysql
启动类
package com.pkfare.zipkin;
import javax.sql.DataSource;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import zipkin.server.EnableZipkinServer;
import zipkin.storage.mysql.MySQLStorage;
@EnableZipkinServer
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
@Bean
@Primary
public MySQLStorage mySQLStorage(DataSource datasource) {
return MySQLStorage.builder().datasource(datasource).executor(Runnable::run).build();
}
}