首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在spring-batch-admin应用程序/项目中定义自定义beans的位置

在spring-batch-admin应用程序/项目中定义自定义beans的位置
EN

Stack Overflow用户
提问于 2016-04-19 23:38:41
回答 1查看 94关注 0票数 0

我已经成功地设置了spring-batch-admin示例项目。现在我开始将我的自定义bean注入到项目阅读器、项目处理器等中。

我已经在WEB-INF内的applicationContext.xml中定义了我的自定义bean。但在运行作业时,我仍然得到No bean命名为已定义的异常。

TestReader.java

代码语言:javascript
复制
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中定义了servlet bean,并将其包含在TestAutoWire -config.xml文件中。

任何帮助都将不胜感激。感谢并致以问候

EN

回答 1

Stack Overflow用户

发布于 2016-04-20 00:08:30

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36723156

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档