相关文章推荐

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected behavior:

As documented here , it is expected that spring-kafka 2.7.X is compatible with spring-boot-starter-web 2.5.X.

Actual behavior:

When using spring-kafka 2.7.8 with spring-boot-starter-web 2.5.X , a runtime error prevents the application from starting.
Note that the issue does not occur when using spring-kafka 2.7.7.

The error is the following:

2021-10-22 02:07:39.428 WARN 10344 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor': Cannot resolve reference to bean 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' while setting bean property 'metadataReaderFactory'; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.expression.spel.support.StandardTypeConverter.(Ljava/util/function/Supplier;)V
2021-10-22 02:07:39.640 ERROR 10344 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

APPLICATION FAILED TO START

Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:160)

The following method did not exist:
org.springframework.expression.spel.support.StandardTypeConverter.(Ljava/util/function/Supplier;)V

Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.expression.spel.support.StandardTypeConverter

To reproduce:

Create a simple spring boot application with both dependencies and try starting it.

Please show your pom.

Most likely you are specifying versions for Spring jars and you have mismatched versions (e.g. spring-messaging 5.3.9 and spring-beans 5.3.7). All Spring Framework jars must be the same version.

When using Spring Boot, it's best to let Boot manage the version of all dependencies.

This is the pom file:
https://github.com/pragmatest-mt/github-actions-demo/blob/kafka-issue/pom.xml

I tried removing all dependencies except for spring-kafka and spring-boot-starter-web and the issue is reproduced.

Can anyone help me if I am using org.springframework.boot:2.7.10 what should be the version of org.springframework.kafka:spring-kafka: and testImplementation "org.springframework.kafka:spring-kafka-test because I am getting this error with 2.6.5 version: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedKafka': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: kafka.utils.TestUtils.boundPort(Lkafka/server/KafkaServer;Lorg/apache/kafka/common/security/auth/SecurityProtocol;)I

@sheetalj2205 See the compatibility matrix on the project page: https://spring.io/projects/spring-kafka

Generally, when using Boot you should use its dependency management (and don't specify any version) and Boot will bring in the correct compatible version. However, 2.7.x brings in 2.8.x by default (which is out of OSS support https://spring.io/projects/spring-kafka#support ) so you should be using 2.9.8 (latest) or later.

 
推荐文章