實例主要有三個工程組成:java
兩個服務能夠相互調用,服務相互調用以後能夠經過Service-Zipkin收集數據進行鏈路追蹤。git
POM:github
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-server</artifactId> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-autoconfigure-ui</artifactId> </dependency> </dependencies>
POM:web
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> </dependencies>
properties:spring
spring.application.name=service-01 server.port=7001 spring.zipkin.base-url=http://localhost:9400 #zipkin地址
應用互相調用:api
@RequestMapping(value = "/api", method = RequestMethod.GET) public String api() { return restTemplate.getForEntity( "http://localhost:7002/hi", String.class).getBody(); }
經過:http://10.168.12.25:9400/dependency 查看服務引用;springboot
https://github.com/zhangcj/easymall/tree/master/springbootdemo/springbootdemo-zipkinapp