java.lang.NoSuchFieldError:IMPORT_BEAN_NAME_GENERATOR

我有一个带有以下注释的单元测试:

@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestConfiguration.class)
@TestPropertySource("classpath:application-test.properties")

我使用Spring Boot 2.2.0,Spring 5.2.0和Junit Jupiter。该测试使用内存中的H2数据库测试dao类。在我切换到Spring Boot 2.2.0之前,这曾经可以工作。 我收到错误消息

java.lang.NoSuchFieldError: IMPORT_BEAN_NAME_GENERATOR

调试时我看到

@Override
@Deprecated
public void registerBeanDefinitions(Annotationmetadata metadata,BeanDefinitionRegistry registry) {
    registerBeanDefinitions(metadata,registry,ConfigurationClasspostProcessor.IMPORT_BEAN_NAME_GENERATOR);
}
在RepositoryBeanDefinitionRegistrarSupport类中的

。我在registerBeanDefinitions上遇到了例外。该方法已弃用,文档说明该方法已被具有三个参数here的方法所取代。当我在定义了ConfigurationClasspostProcessor的{​​{1}}中设置断点时,代码没有到达那里。显然,有些东西正在使用旧方法,但我无法确定是什么。回到Spring Boot 2.1.8时,没有出现此错误。

guangguang198 回答:java.lang.NoSuchFieldError:IMPORT_BEAN_NAME_GENERATOR

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3153300.html

大家都在问