添加部分:设置了zipkin的访问端口
zipkin: base-url: http://localhost:9411 sleuth: sampler: probability: 1 server: port: 8001 spring: application: name: cloud-payment-service datasource: type: com.alibaba.druid.pool.DruidDataSource #当前数据源的操作类型 driver-class-name: com.mysql.jdbc.Driver #mysql驱动包 url: jdbc:mysql:///db2020?characterEncoding=utf8&serverTimezone=GMT+8 username: root password: 25002500 jpa: show-sql: true zipkin: base-url: http://localhost:9411 sleuth: sampler: probability: 1 mybatis: mapper-locations: classpath:mapper/*.xml type-aliases-package: cn.kitey.springcloud.entities #所有的Entity所在的包 eureka: client: register-with-eureka: true # 是否注册自己的信息到EurekaServer,默认是true fetch-registry: true # 是否拉取其它服务的信息,默认是true service-url: # EurekaServer的地址,现在是自己的地址,如果是集群,需要加上其它Server的地址。 # defaultZone: http://localhost:7001/eureka #下面的为集群版 defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka # 单机模式 # defaultZone: http://eureka7001.com:7001/eureka instance: # 主机名的修改 instance-id: payment8001 #访问路径可以显示ip地址 prefer-ip-address: true # # #Eureka客户端向服务器发送的时间间隔,默认30秒 # lease-renewal-interval-in-seconds: 1 # #Eureke服务端在收到最后一次信息后等待的时间上线,默认90秒 # lease-expiration-duration-in-seconds: 2成功访问则会返回: hello Zipkin
@GetMapping("/payment/zipkin") public String paymentZipkin(){ return "hello Zipkin"; }添加: 跟8001添加的一样
zipkin: base-url: http://localhost:9411 sleuth: sampler: probability: 1调用8001中的方法
@GetMapping("consumer/payment/zipkin") public String paymentZipkin(){ String result = restTemplate.getForObject("http://localhost:8001"+ "/payment/zipkin/", String.class); return result; }