我想让我的spring启动应用程序在启动时失败,如果它无法连接到kafka代理。我的应用程序只是向主题发布消息。我将此行添加到我的属性文件中但到目前为止没有运气spring.kafka.admin.fail-fast=true
。
fail-fast
仅在上下文中至少有一个NewTopic
bean时才会起作用(因此管理员将尝试检查该主题是否存在,如果不存在则创建它)。
@SpringBootApplication
public class So55177700Application {
public static void main(String[] args) {
SpringApplication.run(So55177700Application.class, args);
}
@Bean
public NewTopic topic() {
return new NewTopic("so55177700", 1, (short) 1);
}
}
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-03-15 09:42:49.555 ERROR 41793 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Could not configure topics