我试图在春天跑骆驼。以下是我的文件..
<properties> <spring.version>3.2.11.RELEASE</spring.version> <camel.version>2.14.1</camel.version> </properties> <?xml version="1.0" encoding="UTF-8"?> <dependencies> <!-- camel core --> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <version>${camel.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-spring</artifactId> <version>${camel.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-metrics</artifactId> <version>${camel-version}</version> </dependency> <!-- Spring 3 dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> </dependencies>
<camel:camelContext trace="false" id="mc-service-camel-context" threadNamePattern="Camel (#camelId#) thread ##counter# - #name#"> <camel:contextScan/> </camel:camelContext>
@Component public class MyRoute extends RouteBuilder { @Override public void configure() throws Exception { from("timer://runOnce?repeatCount=1&delay=5000") .log("Hello World!!") .end(); } }
public static void main(String[] args) throws InterruptedException { AbstractXmlApplicationContext appContext = new ClassPathXmlApplicationContext("main-context.xml"); Thread.sleep(100000); }
问题是我没有看到日志“Hello World”。有人可以给我一些关于我失踪的反馈吗。
答案 0 :(得分:1)
我必须启用组件扫描。
<context:annotation-config/>
<context:component-scan base-package="com.mycompany.app*" />