Java 驼峰组件看不到数据源
这里是我的JavaConfigSpring3.2.4,camel2.13.4,它创建camelContext和数据源 我有junit4测试类Java 驼峰组件看不到数据源,java,spring,apache-camel,spring-jdbc,Java,Spring,Apache Camel,Spring Jdbc,这里是我的JavaConfigSpring3.2.4,camel2.13.4,它创建camelContext和数据源 我有junit4测试类 @RunWith(CamelSpringJUnit4ClassRunner.class) @ContextConfiguration(classes = BeansConfig.class,loader = CamelSpringDelegatingTestContextLoader.class) public class Came
@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = BeansConfig.class,loader = CamelSpringDelegatingTestContextLoader.class)
public class CamelTestSpring {
@Autowired
private CamelContext camelContext;
@Autowired
private DataSource dataSource;
@Before
public void setUpContext() throws Exception {
camelContext.getProperties().put(Exchange.LOG_DEBUG_BODY_MAX_CHARS, "1500");
camelContext.addRoutes(routeBuilder());
producerTemplate = camelContext.createProducerTemplate();
Endpoint endpoint = camelContext.getEndpoint("direct:inSql");
producerTemplate.setDefaultEndpoint(endpoint);
camelContext.start();
}
@After
public void cleanUpContext() throws Exception {
camelContext.stop();
}
public RouteBuilder routeBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:inSql").to("sql:select * from dual");
}
};
}
@Test
public void testDatasourse() {
producerTemplate.sendBody("test");
}
}
我的问题是,尽管数据源存在并正确注入,但当我运行route时,camelContext看不到数据源。我尝试了从direct:inSql.tosql:select*from-dual?dataSource=dataSource路由;但这并没有帮助
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: dataSource of type: javax.sql.DataSource
我的错误是什么?如何解决
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: dataSource of type: javax.sql.DataSource