当前位置: 首页 > 知识库问答 >
问题:

发布兼容性问题:java.lang.nosuchmethoderror

申屠泳
2023-03-14
        Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2018-04-12 10:48:34.501 ERROR 13141 --- [           main] o.s.boot.SpringApplication               : Application run failed

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kafkaListenerContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/kafka/KafkaAnnotationDrivenConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory]: Factory method 'kafkaListenerContainerFactory' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.NoSuchMethodError: org.springframework.kafka.listener.config.ContainerProperties.setClientId(Ljava/lang/String;)V
            at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
            at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:758)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
            at Server.main(Server.kt:19)
    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory]: Factory method 'kafkaListenerContainerFactory' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.NoSuchMethodError: org.springframework.kafka.listener.config.ContainerProperties.setClientId(Ljava/lang/String;)V
            at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
            at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)
            ... 18 common frames omitted
    Caused by: java.lang.BootstrapMethodError: java.lang.NoSuchMethodError: org.springframework.kafka.listener.config.ContainerProperties.setClientId(Ljava/lang/String;)V
            at org.springframework.boot.autoconfigure.kafka.ConcurrentKafkaListenerContainerFactoryConfigurer.configureContainer(ConcurrentKafkaListenerContainerFactoryConfigurer.java:99)
            at org.springframework.boot.autoconfigure.kafka.ConcurrentKafkaListenerContainerFactoryConfigurer.configure(ConcurrentKafkaListenerContainerFactoryConfigurer.java:80)
            at org.springframework.boot.autoconfigure.kafka.KafkaAnnotationDrivenConfiguration.kafkaListenerContainerFactory(KafkaAnnotationDrivenConfiguration.java:72)
            at org.springframework.boot.autoconfigure.kafka.KafkaAnnotationDrivenConfiguration$$EnhancerBySpringCGLIB$$b9d721e8.CGLIB$kafkaListenerContainerFactory$1(<generated>)
            at org.springframework.boot.autoconfigure.kafka.KafkaAnnotationDrivenConfiguration$$EnhancerBySpringCGLIB$$b9d721e8$$FastClassBySpringCGLIB$$25044a84.invoke(<generated>)
            at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
            at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
            at org.springframework.boot.autoconfigure.kafka.KafkaAnnotationDrivenConfiguration$$EnhancerBySpringCGLIB$$b9d721e8.kafkaListenerContainerFactory(<generated>)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
            ... 19 common frames omitted
    Caused by: java.lang.NoSuchMethodError: org.springframework.kafka.listener.config.ContainerProperties.setClientId(Ljava/lang/String;)V
            at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
            at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975)
            at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000)
            at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1394)
            at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1750)
            at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
            ... 32 common frames omitted

根据Artem Bilan在这篇random gitter线程中的说法,Spring-Boot2仅与spring-kafka 2.1.x兼容。我找不到任何文件说明这一点。

考虑到所有这些,这是我唯一的选择:

>

  • 升级到kafka 1.0,因为spring-kafka 2.1仅与kafka 1.0兼容。

    是否存在允许Spring-Boot2和Spring-Kafka旧版本之间兼容的东西?

  • 共有1个答案

    沈博涉
    2023-03-14

    我确实喜欢在POM中这样降级斯普林Kafaka:

    <properties>
        <spring-kafka.version>2.0.4.RELEASE</spring-kafka.version>
    </properties>
    

    然后得到相同的nosuchmethoderror。从那里,我跳到ConcurrentKafKalistenerContainerFactoryConfigureer,并决定根据KafKaAnnotationDrivenConfiguration重写它:

    @Bean
    public ConcurrentKafkaListenerContainerFactoryConfigurer kafkaListenerContainerFactoryConfigurer(
            KafkaProperties kafkaProperties,
            ObjectProvider<RecordMessageConverter> messageConverterObjectProvider,
            ObjectProvider<KafkaTemplate<Object, Object>> kafkaTemplateObjectProvider) {
    
        RecordMessageConverter messageConverter = messageConverterObjectProvider.getIfUnique();
        KafkaTemplate<Object, Object> kafkaTemplate = kafkaTemplateObjectProvider.getIfUnique();
    
        return new ConcurrentKafkaListenerContainerFactoryConfigurer() {
    
            @Override
            public void configure(ConcurrentKafkaListenerContainerFactory<Object, Object> listenerFactory,
                    ConsumerFactory<Object, Object> consumerFactory) {
    
                listenerFactory.setConsumerFactory(consumerFactory);
                configureListenerFactory(listenerFactory);
                configureContainer(listenerFactory.getContainerProperties());
            }
    
            private void configureListenerFactory(
                    ConcurrentKafkaListenerContainerFactory<Object, Object> factory) {
                PropertyMapper map = PropertyMapper.get();
                KafkaProperties.Listener properties = kafkaProperties.getListener();
                map.from(properties::getConcurrency).whenNonNull().to(factory::setConcurrency);
                map.from(() -> messageConverter).whenNonNull()
                        .to(factory::setMessageConverter);
                map.from(() -> kafkaTemplate).whenNonNull().to(factory::setReplyTemplate);
                map.from(properties::getType).whenEqualTo(KafkaProperties.Listener.Type.BATCH)
                        .toCall(() -> factory.setBatchListener(true));
            }
    
            private void configureContainer(ContainerProperties container) {
                PropertyMapper map = PropertyMapper.get();
                KafkaProperties.Listener properties = kafkaProperties.getListener();
                map.from(properties::getAckMode).whenNonNull().to(container::setAckMode);
                map.from(properties::getAckCount).whenNonNull().to(container::setAckCount);
                map.from(properties::getAckTime).whenNonNull().as(Duration::toMillis)
                        .to(container::setAckTime);
                map.from(properties::getPollTimeout).whenNonNull().as(Duration::toMillis)
                        .to(container::setPollTimeout);
                map.from(properties::getNoPollThreshold).whenNonNull()
                        .to(container::setNoPollThreshold);
                map.from(properties::getIdleEventInterval).whenNonNull().as(Duration::toMillis)
                        .to(container::setIdleEventInterval);
                map.from(properties::getMonitorInterval).whenNonNull().as(Duration::getSeconds)
                        .as(Number::intValue).to(container::setMonitorInterval);
            }
    
        };
    }
    

    对,这主要是复制粘贴,但至少我停下来获取异常并尽可能多地传播属性。

     类似资料:
    • 我一直在我的笔记本电脑上使用lwjgl和GLSL 1.3进行一个项目。我的着色器在我的笔记本电脑上编译得很好,但是,当尝试在我的桌面上编译相同的着色器时,它有一个更新的显卡,我收到一个错误,说明着色器无法编译,因为着色器中存在错误。但是,着色器日志不会输出任何错误。我认为GLSL向后兼容它自己。 返回 我假设它与标准的GLSL 3.30相同。这是一个示例vertandfrag着色器,它适用于我的笔

    • 3.1 可以在什么样的硬件系统上运行? Debian GNU/Linux 包含所有程序的完整源代码, 因此可以在所有Linux内核支持的硬件系统上运行; 详见 Linux FAQ. Debian GNU/Linux 现在的版本是 8, 包括在以下硬件系统上运行的完整的源代码和二进制程序: i386: 指基于 Intel 和兼容处理器的 PC 机,包括Intel的 386, 486, Pentium

    • 我们在div里放一个img,发现: 在html和html5中,div的长宽是不同的,后者的高度要超过几个像素。 比如说,下面这个是html的。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css">

    • 当我尝试sbt构建我的项目时,项目构建失败,出现“Extracting product structure failed”错误。我怀疑一些与我使用的Alpakka和Akka版本有关的东西。 下面是我的build.sbt文件: gael:下面是来自Intellij的错误消息的图像 运行时,我得到以下错误堆栈:

    • 更新 这是一个专门针对几个if项目的问题,因此,如果需要,请询问更多细节,我将尽力提供。 问题:我使用的WordPress主题称为白石(http://themeforest.net/item/white-rock-restaurant-winery-theme/3317744)。此主题与WooCommerce没有内置兼容性。然而,我已经设法让99%的事情与一些代码更改和其他插件一起工作。当您浏览到

    • Android-ndk\toolchains\arm-linux-androideabi-4.4.3对于x86,使用路径:Android-ndk\toolchains\x86-4.4.3有关更多信息,请参见位于Android-ndk/docs/standalone-toolchain.html中的NDK文档。 但是,从这个简短的描述中,我不明白什么是工具链兼容性问题。我想知道是否有人能更详细地向我