编程语言
首页 > 编程语言> > java – 加载spring camel context(类型不匹配)时出错

java – 加载spring camel context(类型不匹配)时出错

作者:互联网

我在一个带有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");
}
}

驼峰上下文代码是:

<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,apache-camel,apache-servicemix
来源: https://codeday.me/bug/20190709/1413999.html