在spring-batch-admin应用程序/项目

时间:2016-04-19 15:38:41

标签: java spring spring-batch spring-batch-admin

我已经成功设置了spring-batch-admin示例项目。现在我开始将自定义bean注入itemreader,itemprocessor等。

我在WEB-INF里面的applicationContext.xml中定义了我的自定义bean。但仍然在运行工作时,我得到没有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中定义了TestAutoWire bean,它包含在servlet-config.xml文件中。

任何帮助将不胜感激。 谢谢和问候

1 个答案:

答案 0 :(得分:0)

确保您的TestReader bean与TestAutoWire bean位于相同的应用程序上下文中。如果没有看到您的上下文文件,我就无法提供更多内容。