功能:查看服务之间的调用关系
1)启动Zipkin Server
下载Zipkin Server
https://dl.bintray.com/openzipkin/maven/io/zipkin/java/zipkin-server/
代码语言:javascript复制java -jar zipkin-server-2.11.6-exec.jar
链接:https://pan.baidu.com/s/11vyNQ9k551foEjeRaBY2Zg 提取码:k9ba
localhost:9411
2) 新建项目A
代码语言:javascript复制<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>
代码语言:javascript复制spring:
zipkin:
base-url: http://localhost:9411
application:
name: zipkin-service-a
server:
port: 8988
代码语言:javascript复制@RestController
public class HelloController {
@RequestMapping("/A")
public String A(){
return "A";
}
}
3)新建项目B
依赖和A一样
yml中端口和名称需要修改
代码语言:javascript复制@RequestMapping("/B")
public String B(){
ResponseEntity<String> forEntity = restTemplate.getForEntity("localhost:项目A地址/A", String.class);
String body = forEntity.getBody();
return body;
}
)结果
先请求一下B项目,使其调用A
然后点击下图中的A就可以出现下图的B
总结
动手实践,加上自己的想法