如何将Apache Camel集成到Java Spring 3.0 web应用程序中以导入数据
我正在开发一个基于Spring 3.0框架的web应用程序
不,我想集成Apache Camel,通过CSV文件将数据导入数据库。我成功地运行了Camel,并在Apache Camel Spring Configuration example之后在数据库中进行了导入
但是现在我想把Camel集成到web应用程序中,这样它就可以一起启动了。但我不知道该怎么做。目前,Camel似乎是在web应用程序旁边启动的,并使用它自己的上下文。特别是,它似乎是在web应用程序之前启动的,因为当Camel尝试自动连接作为web应用程序一部分的数据库存储库时,会引发异常
10:57:36.730 [main] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'routeConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.data.neo4j.repository.GraphRepository com.isarsoftware.ysura.config.RouteConfiguration.graphRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in class path resource [com/isarsoftware/ysura/config/GraphDBConfig.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.repository.GraphRepository com.isarsoftware.ysura.config.GraphDBConfig.userRepository()] threw exception; nested exception is java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Fri Nov 16 10:57:35 CET 2012]; root of context hierarchy
我必须承认,我离成为一名春季专业选手还有很长的路要走。但直到现在,我还是通过阅读博客和教程来让一切正常运转。但对于这个问题,我还没有找到任何指导
有人能给我推荐一个关于谁来解决我的问题的教程或例子吗
# 1 楼答案
见http://camel.apache.org/tutorial-on-using-camel-in-a-web-application.html
基本上,只需将spring listener添加到web中即可。xml文件
然后,创建一个/WEB-INF/applicationContext。xml文件和上下文