我正在微服务工作,微服务正在相互交流。我使用Zipkin和Sleuth以及Apache Kafka作为消息代理,并使用docker-compose运行微服务和Kafka。
我使用的是Spring Boot(2.2.6.release)、Spring Cloud(Hoxton.sr3)、Kafka Image(Wurstmeister/Kafka:2.12-2.4.1)和Zipkin的最新Image。
在org.springframework.cloud.sleuth.zipkin2.zipkinautoConfiguration>中,方法报告器的参数2需要一个类型为“zipkin2.reporter.sender”的bean。
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.adi.example</groupId>
<artifactId>currency-conversion-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>currency-conversion-service</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>conversion-server</finalName>
</build>
</project>
Application.properties
spring.application.name=exchange-service
server.port=9000
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true
#eureka.client.service-url.defaultZone=http://localhost:9765/eureka/
eureka.client.service-url.defaultZone=http://eureka-server:9765/eureka/
eureka.instance.prefer-ip-address=true
spring.sleuth.sampler.probability=1
spring.zipkin.base-url=http://zipkin-server:9411/
spring.zipkin.sender.type=kafka
spring.kafka.bootstrap-servers=http://kafka:9092
docker-compose.yml
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper-server
ports:
- "2181:2181"
environment:
- ALLOW_ANONYMOUS_LOGIN= 'yes'
networks:
- service-network
kafka:
image: wurstmeister/kafka:2.12-2.4.1
container_name: kafka-server
ports:
- "9092:9092"
depends_on:
- zookeeper
networks:
- service-network
environment:
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR= 1
- KAFKA_ZOOKEEPER_CONNECT= zookeeper:2181
- KAFKA_LISTENERS= PLAINTEXT://:9092
- KAFKA_ADVERTISED_LISTENERS= PLAINTEXT://:9092
eureka-server:
image: discovery-server:1.0.0
restart: always
depends_on:
- zipkin-server
ports:
- "9765:9765"
networks:
- service-network
exchange-server:
image: exchange-server:1.0.0
restart: always
ports:
- "9000:9000"
depends_on:
- eureka-server
networks:
- service-network
conversion-server:
image: conversion-server:1.0.0
restart: always
ports:
- "9100:9100"
depends_on:
- eureka-server
- exchange-server
networks:
- service-network
zipkin-server:
image: openzipkin/zipkin
ports:
- "9411:9411"
restart: always
depends_on:
- zookeeper
networks:
- service-network
networks:
service-network:
console-log
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.6.RELEASE)
2020-04-22 15:03:47.165 INFO [exchange-service,,,] 1 --- [ main] c.e.d.CurrencyExchangeServiceApplication : No active profile set, falling back to default profiles: default
2020-04-22 15:03:51.847 INFO [exchange-service,,,] 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=a980a587-b2e4-3cb6-b4e7-9abfad8a56f8
2020-04-22 15:03:55.619 INFO [exchange-service,,,] 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9000 (http)
2020-04-22 15:03:55.687 INFO [exchange-service,,,] 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-04-22 15:03:55.688 INFO [exchange-service,,,] 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
2020-04-22 15:03:55.890 INFO [exchange-service,,,] 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-04-22 15:03:55.893 INFO [exchange-service,,,] 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 8565 ms
2020-04-22 15:03:56.382 ERROR [exchange-service,,,] 1 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'tracingFilter' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceWebServletAutoConfiguration.class]: Unsatisfied dependency expressed through method 'tracingFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'httpTracing' defined in class path resource [org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.class]: Unsatisfied dependency expressed through method 'httpTracing' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tracing' defined in class path resource [org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'tracing' parameter 6; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'zipkinReporter' defined in class path resource [org/springframework/cloud/sleuth/zipkin2/ZipkinAutoConfiguration.class]: Unsatisfied dependency expressed through method 'reporter' parameter 2; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'zipkin2.reporter.Sender' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=zipkinSender)}
2020-04-22 15:03:56.443 INFO [exchange-service,,,] 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-04-22 15:03:56.472 WARN [exchange-service,,,] 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-04-22 15:03:56.522 INFO [exchange-service,,,] 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-04-22 15:03:57.082 ERROR [exchange-service,,,] 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
Description:
Parameter 2 of method reporter in org.springframework.cloud.sleuth.zipkin2.ZipkinAutoConfiguration required a bean of type 'zipkin2.reporter.Sender' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'rabbitSender' in 'ZipkinRabbitSenderConfiguration' not loaded because @ConditionalOnProperty (spring.zipkin.sender.type=rabbit) found different value in property 'spring.zipkin.sender.type'
- Bean method 'restTemplateSender' in 'ZipkinRestTemplateSenderConfiguration' not loaded because ZipkinSender org.springframework.cloud.sleuth.zipkin2.sender.ZipkinRestTemplateSenderConfiguration kafka sender type
Action:
Consider revisiting the entries above or defining a bean of type 'zipkin2.reporter.Sender' in your configuration.
MainApp.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import brave.sampler.Sampler;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients("com.example")
public class MainApp {
public static void main(String[] args) {
SpringApplication.run(CurrencyConversionServiceApplication.class, args);
}
@Bean
public Sampler sampler() {
return Sampler.ALWAYS_SAMPLE;
}
}
错误背后的原因是我忘记在pom.xml中添加kafka依赖项,在添加依赖项后,错误就消失了。
问题内容: 添加此内容以供他人参考,因为如果存在这样的答案,那将节省我10分钟。 我尝试使用ubuntu 14.0LTS virtualbox安装Docker 但是,当我尝试运行docker时,出现以下错误 为什么Ubuntu看不到Docker? 问题答案: Ubuntu软件包实际上是指GUI应用程序,而不是我们要寻找的最受欢迎的DevOps工具。 ===更新(感谢@Scott Stensland
我在Zipkin中找不到以下可导出的Span,既不是通过traceId也不是通过spanId(出现了一些其他Span,所以Zipkin服务器似乎可以工作) 我也找不到它的父级“parentID”:“37ECA1021FD5241C”在Zipkin。 哪里会有问题?我怎么咬/调试它? 这个跨度可能在一个流中,它是由一个rabbit消息触发的,而不是一个rest请求。由http rest请求触发的跟踪
问题内容: 我正在使用 一个简单的docker-compose脚本。 我使用运行该脚本。这将创建我的2个容器,但仅在我的主容器上(从此处执行命令)创建容器。我希望在主机上创建一个,在节点上创建一个。我也尝试添加 和 每次服务后,但这都失败了: 当我执行网络创建时 有人可以通过docker- compose帮助我在2个节点上部署2个容器。Swarm正在为我的“集群”工作。我按照本教程进行了验证。 问
问题内容: 当我尝试运行express创建的文件时,出现以下错误: 当我键入时,我得到一个return语句。我用npm安装Express。我必须按照以下说明手动创建npm: 错误是。 安装npm和express之后,是否需要做一些事情才能使express看到npm创建的模块? 我的节点是版本:0.4.6 我的快递是版本:2.3.3 我的npm是版本:1.0.6 Express已全局安装。我用标志来
问题内容: 使用Java Selenium Firefox geckodriver时出现问题。这是问题所在: OS:Windows 7 selenium ersion:Selenium 3.0.0 beta4 Java:8 Geckodriver:v0.10.0 Error msg: Exception in thread “main” java.lang.NoClassDefFoundError
我有一个烧瓶服务器运行在http://127.0.0.1:5000和一个vuejs前端运行http://localhost:8080我已经做了api,并用postman测试了它,一切都如预期的那样工作:( > 将请求发布到/登录- (将请求发送至/登录)- 烧瓶API代码: 登录。vue: 指数vue 当我使用邮递员登录时,我得到的响应为;当我使用邮递员获取url/索引时,我得到响应。数据但当我使