从 kafka 主题读取时出现异常: 原因:org.apache.kafka.common.errors.SerializationException:反序列化 id 1 的 Avro 消息时出错 原因:org.apache.kafka.common.errors.SerializationException:找不到类 USERS在作者模式中指定,同时查找特定记录的读者模式。
我认为反序列化是不正确的,我也找不到任何合适的例子。
Properties props = new Properties();
props.put(StreamsConfig.APPLICATION_ID_CONFIG , "TEST");
props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG,"localhost:9092");
props.put(AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, "http://localhost:8081");
props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG,Serdes.String().getClass().getName());
props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG,SpecificAvroSerde.class);
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
props.put(KafkaAvroDeserializerConfig.SPECIFIC_AVRO_READER_CONFIG, true);
StreamsBuilder builder = new StreamsBuilder();
KStream<String,USERS> valid = builder.stream("testUSERS");
valid.foreach((k,v)-> System.out.println("v ="+v.getUSERNAME()));
valid.foreach((k,v)-> System.out.println("k ="+k));
KafkaStreams streams = new KafkaStreams(builder.build(),props);
streams.cleanUp();
streams.start();
Run Code Online (Sandbox Code Playgroud) java avro apache-kafka apache-kafka-streams confluent-schema-registry
运行应用程序时出现以下错误。请任何人帮助我理解我做错了什么,
在文件 [C:\Users\Admin1\Login.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\MVC\WEB-INF\classes\Validation\user .class]:通过构造函数参数0表示的不满足的依赖;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的“java.lang.String”类型的合格 bean:预计至少有 1 个 bean 有资格作为自动装配候选。依赖注释:{}
package Validation;
import java.util.Date;
import org.springframework.stereotype.Repository;
import DAO.Processor;
import javax.validation.constraints.Past;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
@Repository
@Entity
@Table(name = "APP_USER", schema = "claim")
public class user {
@Id
private int uid;
@OneToOne
@JoinColumn(name = "PID")
Processor P;
@NotNull
String username = null;
@NotNull
String password;
public Processor getP() {
return P;
}
public void setP(Processor p) {
P = p;
}
@NotNull
String …Run Code Online (Sandbox Code Playgroud)