gpt4 book ai didi

java - 与 spring xml 函数 camelContext 的参数不兼容

转载 作者:行者123 更新时间:2023-11-29 09:02:48 25 4
gpt4 key购买 nike

嗨,请原谅我的知识不足,但我是使用 spring 和 camel 的初学者。我正在尝试制作一个简单的 camelContext bean,它将消息从端点路由到另一个名为 smartlighting 的 spring bean。问题是每当我在 xml 中初始化 camelContext 甚至是空的时,我都会得到这个奇怪的“函数参数不兼容”异常。

我正在使用 spring 3.0 & camel 2.10.3 & tomcat 服务器 v7.0

我的spring xml如图:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
">

<camelContext id="camelcontext" xmlns="http://camel.apache.org/schema/spring">
<route streamCache="true">
<from uri="jetty:http://192.168.1.99:1989/sample/endpoint"/>
<bean ref="smartlighting" method="test"/>
</route>
</camelContext>


<bean id="smartlighting" class="com.example.smartlighting.SmartLightingApp" init-method="init"/>

</beans>

每当我运行项目时我都会得到这个异常

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.VerifyError: (class: org/apache/camel/spring/CamelContextFactoryBean, method: initThreadPoolProfiles signature: (Lorg/apache/camel/CamelContext;)V) Incompatible argument to function
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:458)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:388)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

最佳答案

您可以在上下文文件中将 camel 命名空间设为默认命名空间,并使用 beans 别名引用 spring bean。
例如:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://camel.apache.org/schema/spring" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<beans:bean id="smartlighting" class="com.example.smartlighting.SmartLightingApp" init-method="init"/>

<camelContext id="camelcontext" xmlns="http://camel.apache.org/schema/spring">
<route streamCache="true">
<from uri="{{your}}"/>
<bean ref="smartlighting" method="test"/>
</route>
</camelContext>
</beans:beans>

关于java - 与 spring xml 函数 camelContext 的参数不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16401411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com