本文介绍了提供了 kafka schema.registry.url 但不是已知的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试使用架构注册表发布关于主题的 json 消息,但出现以下错误.以下spring引导方法
...
Trying to publish the json message on topic using schema registry but getting below error. followingspring boot approach
..
提供了配置schema.registry.url"但不是已知配置
The configuration 'schema.registry.url' was supplied but isn't a known config
应用 yml 文件
application yml fle
server:
port: 9080
spring:
kafka:
properties:
bootstrap.servers: server1:8080
schema.registry.url: https://bctdsdg:8081/
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: JsonSerializer.class
ssl:
keystore-location: classpath:cert.jks
keystore-password: pwd
key-password: pwd
truststore-location: classpath:dev_cacerts.jks
truststore-password: pwd
kafka 配置
kafka configuation
@Configuration
@EnableKafka
public class KafkaConfig {
@Autowired
private KafkaProperties kafkaProperties;
@Bean
public Map<String, Object> producerConfigs() {
Map<String, Object> props = new HashMap<>();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaProperties.getBootstrapServers());
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, com.schemaregjson.serdes.JsonSerializer.class);
props.put("schema.registry.url", "https://bctdsdg:8081/");
props.putAll(kafkaProperties.getSsl().buildProperties());
props.putAll(kafkaProperties.getProperties());
return props;
}
@Bean
public ProducerFactory<String, User> producerFactory() {
return new DefaultKafkaProducerFactory<>(producerConfigs());
}
@Bean
public KafkaTemplate<String, User> kafkaTemplate() {
return new KafkaTemplate<>(producerFactory());
}
}
----------------------------------------------
----------------------------------------------
@SpringBootApplication
public class SchemaregjsonApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(SchemaregjsonApplication.class, args);
}
@Autowired
private JsonProducer jsonproducer;
User user = new User().withAge(34).withFirstname("Don").withLastname("Joe");
@Override
public void run(String... args) throws Exception {
jsonproducer.send(user);
}
}
推荐答案
在生产者和消费者属性下配置架构注册表 URL.
configure schema registry url under producer and consumer properties.
应用 yml 文件
application yml fle
spring:
kafka:
bootstrap.servers: server1:8080
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: JsonSerializer.class
properties:
schema.registry.url: http://localhost:8081
ssl:
keystore-location: classpath:cert.jks
keystore-password: pwd
key-password: pwd
truststore-location: classpath:dev_cacerts.jks
truststore-password: pwd
这篇关于提供了 kafka schema.registry.url 但不是已知的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!