쩨이엠 개발 블로그

[spring batch] EL1008E: Property or field 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public or not valid? 본문

개발/Spring

[spring batch] EL1008E: Property or field 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public or not valid?

쩨이엠 2024. 12. 30. 14:07
728x90
반응형

Spring batch에서 ItemReader를 쓰다 발견한 에러

 

EL1008E: Property or field 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public or not valid?

 

이 경우엔 jobParameters를 받는 bean의 scope를 지정해주지 않아 발생하는 에러로

@StepScope @JobScope를 넣어주면 된다

 
    @Bean
    @StepScope
    public RepositoryItemReader<Trx> trxReader(@Value("#{jobParameters[targetDate]}") LocalDateTime targetDate) {
        log.info("startDt : {}, endDt : {}", targetDate.minusMinutes(5), targetDate);
        return new RepositoryItemReaderBuilder<Trx>()
                .name("trxReader")
                .repository(TrxRepository)
                .methodName("findByCreatedDtBetween")
                .pageSize(CHUNK_SIZE)
                .arguments(targetDate.minusMinutes(5), targetDate)
                .sorts(Map.of())
                .build();
    }

 

끝 !

728x90
반응형
Comments