문제

I have a code containing the below snippet running:

class MyNewReader implements ItemReader<MyBean>, ItemStream{    
@Resource
SingleItemPeekableItemReader<MyBean> myBeanPeekableReader;

@Resource
public void setDelegate(MyJdbcReader myJdbcReader){
     myBeanPeekableReader.setDelegate(myJdbcReader);
}

I don't have any property delegate in my class MyNewReader. But still the annotation @Resource is working on setDelegate method and is working fine. Can someone tell that is it not necessary to have a property in the class to let annotation on setter method(having that property in its name) work...Is this not working as setter injection?

도움이 되었습니까?

해결책

myBeanPeekableReader.setDelegate(myJdbcReader) gets its jdbcReader injected as parameter to the method you have annotated.

Yes, setter injection.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top