1, 父Maven pom 文件

 <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.7.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 解决 JDK 9 以上没有 JAXB API 的问题 -->
<!-- <dependency>-->
<!-- <groupId>javax.xml.bind</groupId>-->
<!-- <artifactId>jaxb-api</artifactId>-->
<!-- <version>2.3.0</version>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>com.sun.xml.bind</groupId>-->
<!-- <artifactId>jaxb-impl</artifactId>-->
<!-- <version>2.3.0</version>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>com.sun.xml.bind</groupId>-->
<!-- <artifactId>jaxb-core</artifactId>-->
<!-- <version>2.3.0</version>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>javax.activation</groupId>-->
<!-- <artifactId>activation</artifactId>-->
<!-- <version>1.1.1</version>-->
<!-- </dependency>-->
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

2, Slueth Server 服务器
pom 文件
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<version>2.9.4</version>
</dependency>
</dependencies>

yml 文件
server:
port: 9090

启动类
@SpringBootApplication
@EnableZipkinServer
public class ZipKinServer {
public static void main(String[] args) {
SpringApplication.run(ZipKinServer.class,args);
}
}
-------------------------------------------------

zipkinclient 模块代码
@RestController
@RequestMapping("/zipkin")
public class ZipkinHandler {
@Value("${server.port}")
private String port;

@GetMapping("/index")
public String index(){
return this.port;
}
@RequestMapping("/get")
public String addItem( @RequestParam("desc") String desc){
return "this is zipkin client"+desc;
}
@RequestMapping("/geterro")
public String addI( @RequestParam("desc") String desc){
int m=0;
int n=100/m;
return "this is zipkin client error"+desc;
}
}

3, slueth client

pom 文件
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
</dependencies>

yml 文件

server:
port: 8010
spring:
application:
name: common
sleuth:
web:
client:
enabled: true
sampler:
probability: 1.0
zipkin:
base-url: http://localhost:9090/
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/

启动文件
@EnableFeignClients
@EnableEurekaClient
@SpringBootApplication
public class CommonApp {
public static void main(String[] args) {
SpringApplication.run(CommonApp.class,args);
}

}
----------------------------------------------
@FeignClient(value = "zipkinclient")
public interface FeignInterface {
@GetMapping("/zipkin/get")
public String addItem( @RequestParam("desc") String desc);

@GetMapping("/zipkin/geterro")
public String addI( @RequestParam("desc") String desc);
}

--------------------------------------------------------------

@RestController
public class HelloController {

@RequestMapping("/hello")
public String getHello()
{
return "this is hello world";
}
@Autowired
FeignInterface feign;
@RequestMapping("/get")
public String get()
{
return feign.addItem("this is feign get");
}
@RequestMapping("/mm")
public String mm()
{
return feign.addI("this is feign mmmm");
}
}


最新文章

  1. C和指针 第十五章 习题
  2. 利用Highcharts插件制作动态图表
  3. 利用奇异值分解(SVD)简化数据
  4. spring mvc处理静态资源
  5. 招聘一个靠谱的 iOS程序员
  6. find-all-anagrams-in-a-string
  7. 关于Token
  8. *MySQL卸载之后无法重装,卡在Apply security settings:Error Nr.1045
  9. Android Studio 1.2.2设置显示行号
  10. ORACLE 本地数据库存储过程 调用远程数据库存储过程
  11. 146. 大小写转换 II
  12. BZOJ2828 : 火柴游戏
  13. C++ 中 #ifndef, #define, #endif 宏定义
  14. 【Python】-NO.99.Note.4.Python -【Python3 条件语句 循环语句】
  15. JS----贪吃蛇游戏
  16. android 横竖屏 切换
  17. remove unusable kernel in linux.
  18. tomcat安装配置常见问题详解
  19. JAVA之异常处理(一)
  20. Excel 2010 Alt+; (分号) --- “只选定当前选定区域中的可视单元格”

热门文章

  1. Django 基础05篇 上下文管理和前端代码复用
  2. 如何热更新长缓存的 HTTP 资源
  3. 在Rancher中修改K8S服务参数的万金油法则
  4. 如何在 PyCharm 中设置 Python 代码模板
  5. [考试总结]noip模拟21
  6. Qt 入门 ---- 如何在程序窗口显示图片?
  7. java封装基础详解
  8. 大数据学习(10)—— Hive进阶
  9. Netty入门(一):ByteBuf
  10. 博主从零开始学习HTML(入门基础)