Exception in thread “main” org.apache.kafka.common.KafkaException: Failed create new KafkaAdminClient
at org.apache.kafka.clients.admin.KafkaAdminClient.createInternal(KafkaAdminClient.java:370)
at org.apache.kafka.clients.admin.AdminClient.create(AdminClient.java:62)
at org.apache.kafka.streams.processor.internals.DefaultKafkaClientSupplier.getAdminClient(DefaultKafkaClientSupplier.java:34)
at org.apache.kafka.streams.KafkaStreams.(KafkaStreams.java:707)
at org.apache.kafka.streams.KafkaStreams.(KafkaStreams.java:628)
at org.apache.kafka.streams.KafkaStreams.(KafkaStreams.java:612)
at org.apache.kafka.streams.KafkaStreams.(KafkaStreams.java:602)
at com.bw.Stream.Application.main(Application.java:38)
Caused by: org.apache.kafka.common.config.ConfigException: No resolvable bootstrap urls given in bootstrap.servers
at org.apache.kafka.clients.ClientUtils.parseAndValidateAddresses(ClientUtils.java:66)
at org.apache.kafka.clients.admin.KafkaAdminClient.(KafkaAdminClient.java:409)
at org.apache.kafka.clients.admin.KafkaAdminClient.createInternal(KafkaAdminClient.java:363)
这个错误是没有连接上主机,所以得不到KafkaAdminClient。
我解决的方法是:
在我电脑的hosts文件中配置好kafka对应的主机。
比如:
kafka放到了123.123.123.1这个机器上,在这个机器上配置了主机名为:work1,
这时候我们的机器上的hosts文件配置方式为:
123.123.123.1 work1
保存重新试一下就OK了。