관리 메뉴

개발그래머

Spring Batch 트러블슈팅(warn : org.springframework.batch.item.ItemProcessor is an interface) 본문

Spring/Spring Batch

Spring Batch 트러블슈팅(warn : org.springframework.batch.item.ItemProcessor is an interface)

임요환 2023. 3. 17. 11:13

warn : org.springframework.batch.item.ItemProcessor is an interface. The implementing class will not be queried for annotation based listener configurations. If using @StepScope on a @Bean method, be sure to return the implementing class so listener annotations can be used.

 

번역 : org.springframework.batch.item.ItemProcessor는 인터페이스입니다. 구현 클래스는 주석 기반 리스너 구성에 대해 쿼리 되지 않습니다. @Bean 메서드에서 @StepScope를 사용하는 경우 리스너 주석을 사용할 수 있도록 구현 클래스를 반환해야 합니다.

 

현재 코드 : ItemProcessor 구현체를 사용하지 않고 인터페이스를 그대로 사용하고 있어 경고 발생

@StepScope
@Bean
public ItemProcessor<RestaurantBatchDto, PickRestaurant> restaurantProcessor(){
    return PickRestaurant::new;
}

수정 코드 : CompositeITemProcessor 구현체 사용

@StepScope
@Bean
public CompositeItemProcessor compositeRestaurantProcessor(){
    List<ItemProcessor> delegates = new ArrayList<>(1);
    delegates.add(restaurantProcessor());

    CompositeItemProcessor processor = new CompositeItemProcessor();
    processor.setDelegates(delegates);
    return processor;
}

public ItemProcessor<RestaurantBatchDto, PickRestaurant> restaurantProcessor(){
    return PickRestaurant::new;
}

 

향로님 블로그 참조

https://jojoldu.tistory.com/132