【问题标题】:Where to define Custom beans in spring-batch-admin application/project在 spring-batch-admin 应用程序/项目中定义自定义 bean 的位置
【发布时间】: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


    【解决方案1】:

    确保您的 TestReader bean 与您的 TestAutoWire bean 位于相同的应用程序上下文中。没有看到你的上下文文件,我不能提供更多。

    【讨论】:

      猜你喜欢
      • 2017-08-12
      • 2015-11-11
      • 2020-02-26
      • 2015-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-09
      相关资源
      最近更新 更多