我已经成功地设置了spring-batch管理示例项目。现在我开始将我的自定义bean注入itemreader、itemprocessor等中
我已经在WEB-INF中的applicationContext.xml中定义了我的自定义bean。但在运行作业时,我仍然得到了No-bean命名的已定义异常。
TestReader.java
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import org.springframework.beans.factory.annotation.Autowired;
public class TestReader implements ItemReader<String>{
@Autowired
private TestAutoWire testAutoWire;
@Override
public String read() throws Exception, UnexpectedInputException,
ParseException, NonTransientResourceException {
// TODO Auto-generated method stub
System.out.println("test");
return null;
}
}
我在applicationContext.xml中定义了TestAutoWirebean,它包含在servlet-config.xml文件中。
任何帮助都将不胜感激。感谢和问候
确保您的TestReaderbean与您的TestAutoWirebean处于相同的应用程序上下文中。如果没有看到你的上下文文件,我就无法提供更多。