创建名为“jpabatchconfigurer”的bean时出错:调用init方法失败;嵌套异常为java.lang.nosuchfielderror:

crcmnpdw  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(275)

这是我的批处理配置文件。我正在尝试从postgressql数据库获取用户数据库。

@Configuration
@EnableBatchProcessing
public class BatchConfiguration {

    private static final Logger log = LoggerFactory.getLogger(BatchConfiguration.class);

    @Autowired
    SpringLiquibase liquibase;

    @Bean
    public Job job(JobBuilderFactory jobBuilderFactory,
                   StepBuilderFactory stepBuilderFactory,
                   ItemReader<User> itemReader,
                   ItemProcessor<User, User> itemProcessor,
                   ItemWriter<User> itemWriter
    ) {

        Step step = stepBuilderFactory.get("ETL-file-load")
            .<User, User>chunk(100)
            .reader(itemReader)
            .processor(itemProcessor)
            .writer(itemWriter)
            .build();

        return jobBuilderFactory.get("ETL-Load")
            .incrementer(new RunIdIncrementer())
            .start(step)
            .build();
    }

    @Bean
    public JdbcCursorItemReader<User> itemReader(){
        JdbcCursorItemReader<User> databaseReader = new JdbcCursorItemReader<>();
        databaseReader.setDataSource(liquibase.getDataSource());
        databaseReader.setRowMapper(new BeanPropertyRowMapper<>(User.class));
        databaseReader.setSql("select * from user ju");
        return databaseReader;
    }
    }

我得到以下错误
org.springframework.beans.factory.beancreationexception:创建名为“jpabatchconfigurer”的bean时出错:调用init方法失败;嵌套的异常是java.lang.nosuchfielderror:org.springframework.beans.factory.annotation.initdestroyannotationbeanpostprocessor.postprocessbeforeinitialization(initdestroyannotationbeanpostprocessor)中的块\u不安全\u多态\u基\u类型。java:137)在org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.applybeanpostprocessorsbeforeinitialization(abstractautowirecapablebeanfactory)。java:409)位于org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory)。java:1620)在org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory)。java:555)位于org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory)。java:483)在org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory)。java:306)位于org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry)。java:230)位于org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.com)。java:302)在org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory)。java:197)位于org.springframework.beans.factory.support.defaultlistablebeanfactory.PreInstanceSingletons(defaultlistablebeanfactory)。java:761)在org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext。java:867)在org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext。java:543)在org.springframework.boot.context.embedded.embeddedwebapplicationcontext.refresh(embeddedwebapplicationcontext。java:122)在org.springframework.boot.springapplication.refresh(springapplication。java:693)位于org.springframework.boot.springapplication.refreshcontext(springapplication。java:360)在org.springframework.boot.springapplication.run(springapplication。java:303)在com.admenot.admenotbackendapp.main(backendapp。java:76)在sun.reflect.nativemethodaccessorimpl.invoke0(本机方法)在sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl)。java:62)在sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl。java:43)在java.lang.reflect.method.invoke(方法。java:498)在org.springframework.boot.devtools.restart.restartlauncher.run(restartlauncher。java:49)原因:java.lang.nosuchfielderror:块\不安全\多态\基\类型org.springframework.batch.core.repository.dao.jackson2executioncontextstringserializer.(jackson2executioncontextstringserializer)。java:110)位于org.springframework.batch.core.repository.support.jobrepositoryfactorybean.afterpropertiesset(jobrepositoryfactorybean)。java:192)在org.springframework.boot.autoconfigure.batch.basicbatchconfigurer.createjobrepository(basicbatchconfigurer。java:159)位于org.springframework.boot.autoconfigure.batch.basicbatchconfigurer.initialize(basicbatchconfigurer)。java:119)位于sun.reflect.nativemethodaccessorimpl.invoke0(本机方法)sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl。java:62)在sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl。java:43)在java.lang.reflect.method.invoke(方法。java:498)在org.springframework.beans.factory.annotation.initdestroyannotationbeanpostprocessor$lifecycleelement.invoke(initdestroyannotationbeanpostprocessor)。java:366)位于org.springframework.beans.factory.annotation.initdestroyannotationbeanpostprocessor$lifecyclemetadata.invokeinitmethods(initdestroyannotationbeanpostprocessor)。java:311)在org.springframework.beans.factory.annotation.initdestroyannotationbeanpostprocessor.postprocessbeforeinitialization(initdestroyannotationbeanpostprocessor)。java:134) ... 省略21个公共框架<

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题