gpt4 book ai didi

java - 加载 spring camel 上下文时出错(类型不匹配)

转载 作者:搜寻专家 更新时间:2023-11-01 03:42:01 24 4
gpt4 key购买 nike

我在一个带有 spring camel 上下文、一个路由和一个测试的小项目中使用 Fuse IDE (Eclipse)。我放了一个额外的 xml 来定义测试执行环境。

当我运行测试时,加载上下文 bean 信息时类型不匹配失败(当实例化 bean 上下文的 PropertyDescriptor 类时,setter 类型是 org.apache.camel.spring.SpringCamelContext,getter 类型是 org.apache.camel .model.ModelCamelContext...

原来的异常是:“java.beans.IntrospectionException:读写方法之间的类型不匹配”

测试代码是这样的:

public class TestDBRoute extends CamelSpringTestSupport {   

@DirtiesContext //reload context
@Test
public void testPoll() throws Exception {
//context.start();
System.out.println("comenzo");
Thread.sleep(1000);
System.out.println("termino");
//context.stop();
assertEquals("first", 1, 1);
}

@Override
protected AbstractApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("classpath:/com/test-camel-context.xml");
}
}

Camel 上下文代码是:

<beans xmlns="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">

<camelContext xmlns="http://camel.apache.org/schema/spring">
<packageScan>
<package>com.test.fuse.routes</package>
</packageScan>
</camelContext>
</beans>

路由代码是空的,它只是扩展了RouteBuilder并覆盖了configure方法。

我在 ubuntu 上使用 OpenJDK 1.6.0_24。

如果您需要其他东西,请询问。

谢谢

最佳答案

我只是清理了工作区并在 pom.xml 上将我的 spring 版本从 2.5.4 更改为 2.5.6,一切正常。

感谢 Claud Ibsen 和 Babak Vahdat 的帮助。

关于java - 加载 spring camel 上下文时出错(类型不匹配),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12133883/

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