将Spring应用程序上下文作为父

时间:2015-10-27 16:27:35

标签: java spring mule

Web应用程序如何加载Mule上下文并将Spring上下文作为父项?

我尝试了以下(web.xml)并且无效:

<context-param>
    <param-name>org.mule.config</param-name>
    <param-value>mule-config.xml</param-value>
</context-param>
 <listener>
    <listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class>
</listener> 

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>

 <listener>
    <listener-class>
             org.springframework.web.context.ContextLoaderListener
    </listener-class>

</listener> 

如果我切换侦听器的顺序,则会发生以下异常:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.mule.api.serialization.ObjectSerializer] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1297)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1045)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:940)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:606)
... 46 more

在如上所示的web.xml上加载应用程序,但似乎有两个单独的Spring上下文指向不同的bean。

要使用两个上下文处理mule,需要将以下内容添加到mule-config.xml

<spring:beans>
    <spring:import resource="classpath:applicationContext.xml" />
</spring:beans> 

请告知如何解决这个问题?一个小例子可以很好地演示Web应用程序应如何加载Spring / Mule上下文并最终在Mule中将单个Spring Context作为父类。

谢谢。

0 个答案:

没有答案