6.3. 自动配置的 Camel 上下文
Camel 自动配置提供 CamelContext 实例并创建 SpringCamelContext。它还会初始化并执行该上下文的关闭。此 Camel 上下文在 camelContext bean 名称下的 Spring 应用程序上下文中注册,您可以像其他 Spring bean 一样访问它。
例如,您可以访问 camelContext,如下所示:
@Configuration
public class MyAppConfig {
@Autowired
CamelContext camelContext;
@Bean
MyService myService() {
return new DefaultMyService(camelContext);
}
}