【发布时间】:2016-04-19 15:38:40
【问题描述】:
我已成功设置 spring-batch-admin 示例项目。现在我开始将我的自定义 bean 注入到 itemreader、itemprocessor 等中。
我在 WEB-INF 内的 applicationContext.xml 中定义了我的自定义 bean。但仍然在运行作业时,我得到 No bean named defined 异常。
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 中定义的 TestAutoWire bean,它被包含在 servlet-config.xml 文件中。
任何帮助将不胜感激。 感谢和问候
【问题讨论】:
标签: java spring spring-batch spring-batch-admin