springboot整合kafka配置,spring boot整合kafka

  springboot整合kafka配置,spring boot整合kafka

  

目录

跳靴整合卡夫卡遇到版本不对应如果你的跳羚是2.0.3版本如果你的跳羚比较新,用的2.1.0版本跳羚整合卡夫卡问题的注意事项

 

  

SpringBoot整合kafka遇到版本不对应

跳靴整合卡夫卡需要在跳羚项目里增加卡夫卡的罐子,而最为关键的一点是版本要对应好。

 

  

如果你的SpringBoot是2.0.3版本

父groupIdorg.springframework.boot/groupId artifact id spring-boot-starter-parent/artifact id version2.0.3.RELEASE/version相对路径/!-从存储库/父项中查找父项那么你可以用2.1.7版本的卡夫卡

 

  !-卡夫卡groupIdorg.springframework.kafka/groupId附属地

  

如果你的SpringBoot比较新,用的2.1.0版本

父groupIdorg.springframework.boot/groupId artifact id spring-boot-starter-parent/artifact id version2.1.0.RELEASE/version相对路径/!-从存储库/父项中查找父项那么对应的,你的卡夫卡也应该用新版本

 

  !-https://mvn存储库。com/artifact/org。spring框架。卡夫卡/春天-卡夫卡-依赖groupIdorg.springframework.kafka/groupId当然,版本号可能其他方式也可以。

  不过如果你用2.1.0版本的SpringBoot,却仍使用2.1.7版本的kafka,则会遇到如下错误:

  d : 开发文件 Java JDK 1。8 .0 _ 131 bin Java。exe-xx: tieredstopatlevel=1-无验证-d弹簧。输出。安西。启用=始终-DCOM。星期日管理。JMX远程DCOM。星期日管理。JMX遥控器。港口=8247-DCOM。星期日管理。JMX遥控器。认证=假-DCOM。星期日管理。JMX遥控器。SSL=false-DJ ava。RMI。计算机网络服务器

  e "-javaagent:C:Program FilesJetBrainsIntelliJ IDEA 2018.2.4libidea_rt.jar=8248:C:Program FilesJetBrainsIntelliJ IDEA 2018.2.4bin" -Dfile.encoding=UTF-8 -classpath D:DevelopFilesJavajdk1.8.0_131jrelibcharsets.jar;D:DevelopFilesJavajdk1.8.0_131jrelibdeploy.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextaccess-bridge-64.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextcldrdata.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextdnsns.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextjaccess.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextjfxrt.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextlocaledata.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextnashorn.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextsunec.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextsunjce_provider.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextsunmscapi.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextsunpkcs11.jar;D:DevelopFilesJavajdk1.8.0_131jrelibextzipfs.jar;D:DevelopFilesJavajdk1.8.0_131jrelibjavaws.jar;D:DevelopFilesJavajdk1.8.0_131jrelibjce.jar;D:DevelopFilesJavajdk1.8.0_131jrelibjfr.jar;D:DevelopFilesJavajdk1.8.0_131jrelibjfxswt.jar;D:DevelopFilesJavajdk1.8.0_131jrelibjsse.jar;D:DevelopFilesJavajdk1.8.0_131jrelibmanagement-agent.jar;D:DevelopFilesJavajdk1.8.0_131jrelibplugin.jar;D:DevelopFilesJavajdk1.8.0_131jrelibresources.jar;D:DevelopFilesJavajdk1.8.0_131jrelibrt.jar;D:workspaceIDEAchinaunicomalarm-query-kafkatargetclasses;D:DevelopFilesMavenm2orgspringframeworkbootspring-boot-starter2.1.0.RELEASEspring-boot-starter-2.1.0.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkbootspring-boot2.1.0.RELEASEspring-boot-2.1.0.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkbootspring-boot-autoconfigure2.1.0.RELEASEspring-boot-autoconfigure-2.1.0.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkbootspring-boot-starter-logging2.1.0.RELEASEspring-boot-starter-logging-2.1.0.RELEASE.jar;D:DevelopFilesMavenm2chqoslogbacklogback-classic1.2.3logback-classic-1.2.3.jar;D:DevelopFilesMavenm2chqoslogbacklogback-core1.2.3logback-core-1.2.3.jar;D:DevelopFilesMavenm2orgapachelogginglog4jlog4j-to-slf4j2.11.1log4j-to-slf4j-2.11.1.jar;D:DevelopFilesMavenm2orgapachelogginglog4jlog4j-api2.11.1log4j-api-2.11.1.jar;D:DevelopFilesMavenm2orgslf4jjul-to-slf4j1.7.25jul-to-slf4j-1.7.25.jar;D:DevelopFilesMavenm2javaxannotationjavax.annotation-api1.3.2javax.annotation-api-1.3.2.jar;D:DevelopFilesMavenm2orgspringframeworkspring-core5.1.2.RELEASEspring-core-5.1.2.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkspring-jcl5.1.2.RELEASEspring-jcl-5.1.2.RELEASE.jar;D:DevelopFilesMavenm2orgyamlsnakeyaml1.23snakeyaml-1.23.jar;D:DevelopFilesMavenm2orgslf4jslf4j-api1.7.25slf4j-api-1.7.25.jar;D:DevelopFilesMavenm2orgspringframeworkkafkaspring-kafka2.1.7.RELEASEspring-kafka-2.1.7.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkspring-context5.1.2.RELEASEspring-context-5.1.2.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkspring-aop5.1.2.RELEASEspring-aop-5.1.2.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkspring-beans5.1.2.RELEASEspring-beans-5.1.2.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkspring-expression5.1.2.RELEASEspring-expression-5.1.2.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkspring-messaging5.1.2.RELEASEspring-messaging-5.1.2.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkspring-tx5.1.2.RELEASEspring-tx-5.1.2.RELEASE.jar;D:DevelopFilesMavenm2orgspringframeworkretryspring-retry1.2.2.RELEASEspring-retry-1.2.2.RELEASE.jar;D:DevelopFilesMavenm2orgapachekafkakafka-clients2.0.0kafka-clients-2.0.0.jar;D:DevelopFilesMavenm2orglz4lz4-java1.4.1lz4-java-1.4.1.jar;D:DevelopFilesMavenm2orgxerialsnappysnappy-java1.1.7.1snappy-java-1.1.7.1.jar;D:DevelopFilesMavenm2comalibabafastjson1.2.47fastjson-1.2.47.jar;D:DevelopFilesMavenm2orgapachecommonscommons-lang33.8.1commons-lang3-3.8.1.jar com.unicom.AlarmQueryKafkaApplication . ____ _ __ _ _ /\ / ____ __ _ _(_)_ __ __ _ ( ( )___ _ _ _ / _` \/ ___) _) (_ ) ) ) ) ____ .___ __ ___, / / / / =========_==============___/=/_/_/_/ :: Spring Boot :: (v2.1.0.RELEASE)2018-10-31 19:53:47.061 INFO 14260 --- [ main] com.unicom.AlarmQueryKafkaApplication : Starting AlarmQueryKafkaApplication on SHNWANGC260 with PID 14260 (D:workspaceIDEAchinaunicomalarm-query-kafkatargetclasses started by wangc260 in D:workspaceIDEAchinaunicom)2018-10-31 19:53:47.068 INFO 14260 --- [ main] com.unicom.AlarmQueryKafkaApplication : No active profile set, falling back to default profiles: default2018-10-31 19:53:48.299 INFO 14260 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean org.springframework.kafka.annotation.KafkaBootstrapConfiguration of type [org.springframework.kafka.annotation.KafkaBootstrapConfiguration$$EnhancerBySpringCGLIB$$60ef0a74] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)2018-10-31 19:53:48.524 WARN 14260 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name springConsumer defined in file [D:workspaceIDEAchinaunicomalarm-query-kafkatargetclassescomunicomkafkaSpringConsumer.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name batchFactory defined in class path resource [com/unicom/kafka/kafkaConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.kafka.config.KafkaListenerContainerFactory]: Factory method batchFactory threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory.getContainerProperties()Lorg/springframework/kafka/listener/ContainerProperties;2018-10-31 19:53:48.536 INFO 14260 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with debug enabled.2018-10-31 19:53:48.551 ERROR 14260 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************APPLICATION FAILED TO START***************************Description:An attempt was made to call the method org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory.getContainerProperties()Lorg/springframework/kafka/listener/ContainerProperties; but it does not exist. Its class, org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory, is available from the following locations: jar:file:/D:/DevelopFiles/Maven/m2/org/springframework/kafka/spring-kafka/2.1.7.RELEASE/spring-kafka-2.1.7.RELEASE.jar!/org/springframework/kafka/config/ConcurrentKafkaListenerContainerFactory.classIt was loaded from the following location: file:/D:/DevelopFiles/Maven/m2/org/springframework/kafka/spring-kafka/2.1.7.RELEASE/spring-kafka-2.1.7.RELEASE.jarAction:Correct the classpath of your application so that it contains a single, compatible version of org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactoryProcess finished with exit code 1

 

  

SpringBoot整合kafka问题的注意事项

要想外网的机器可以连接成功需要在kafka的server.properties配置文件中需要如下配置

 

  

 

  这个需要注意一下,填写主机IP的时候不能写localhost,如果这样写外边的主机是无法连接kafka的,需要标明具体的机器外网IP。

  以上为个人经验,希望能给大家一个参考,也希望大家多多支持盛行IT。

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: