骆驼上下文没有在你好世界应用程序中启动
Camel context not starting in hello world app
我正在尝试 运行 spring 中的骆驼。以下是我的文件..
- POM xml 有相关依赖的文件。
<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>
- 主上下文文件 (main-context.xml).
<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();
}
}
- 最后是一个主要的 class,看起来像这样。
public static void main(String[] args) throws InterruptedException {
AbstractXmlApplicationContext appContext = new ClassPathXmlApplicationContext("main-context.xml");
Thread.sleep(100000);
}
问题是我没有看到日志 "Hello World"。有人可以就我所缺少的东西给我一些反馈吗..
我必须启用组件扫描。
<context:annotation-config/>
<context:component-scan base-package="com.mycompany.app*" />
我正在尝试 运行 spring 中的骆驼。以下是我的文件..
- POM xml 有相关依赖的文件。
<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>
- 主上下文文件 (main-context.xml).
<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(); } }
- 最后是一个主要的 class,看起来像这样。
public static void main(String[] args) throws InterruptedException { AbstractXmlApplicationContext appContext = new ClassPathXmlApplicationContext("main-context.xml"); Thread.sleep(100000); }
问题是我没有看到日志 "Hello World"。有人可以就我所缺少的东西给我一些反馈吗..
我必须启用组件扫描。
<context:annotation-config/>
<context:component-scan base-package="com.mycompany.app*" />