我们正在尝试升级kafka客户端2。8.2到3.4.0,使用JAVA 11。但是在构建应用程序时,它失败了。
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.543 sec <<< FAILURE!
testConfigurationNotificationForCMD(com.amadeus.hotel.cde.test.rs.ConfigurationNotificationResourceIntegrationTest) Time elapsed: 0 sec <<< ERROR!
java.lang.NoClassDefFoundError: kafka/common/KafkaException
at org.springframework.kafka.test.context.EmbeddedKafkaContextCustomizer.customizeContext(EmbeddedKafkaContextCustomizer.java:71)
at org.springframework.boot.test.context.SpringBootContextLoader$ContextCustomizerAdapter.initialize(SpringBootContextLoader.java:330)
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:604)
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:373)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:136)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
谁能帮我把kafka-client升级到3需要做什么?4.0
1条答案
按热度按时间tjvv9vkg1#
这里有些奇怪。这个测试显然是试图加载一个名为
kafka.common.KafkaException
的类。但是根据javadoc,真实的的类名是org.apache.kafka.common.KafkaException
。然后我看一下发生这种情况的类的源代码。
https://github.com/spring-projects/spring-kafka/blob/main/spring-kafka-test/src/main/java/org/springframework/kafka/test/EmbeddedKafkaBroker.java
...特别是commit with title:“kafka-clients 3.3.2兼容性”。看起来这次提交之前的测试代码使用的是
kafka.common.KafkaException
!!!所以...我认为你需要更新SpringKafka到v3。0.2或更高版本。
另请参阅SpringKafka v3的release note。0.2版本和this pull request。this commit也是。
最低支持的JAVA版本与kafka-client 3.4.0
Java版本不是问题。这是SpringKafka中的一个回归,显然是由Kafka客户端的变化引起的。你只需要使用SpringKafka的一个版本,并修复了回归。