我已经在2个XML文件中定义了Camel路由,并且希望使用Spring Boot组件运行该应用程序。
这是主要代码:
Object[] sources = {
"META-INF/spring/propertiesContext.xml",
"META-INF/spring/concurrent-route-context.xml"
};
ApplicationContext applicationContext = new SpringApplication(sources).run(args);
CamelSpringBootApplicationController applicationController = applicationContext
.getBean(CamelSpringBootApplicationController.class);
applicationController.blockMainThread();
但是,我在启动时遇到以下错误
2015-08-19 14:54:04.203 ERROR 13812 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.testSpringBoot(ConcurrencyTest.java:44)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.main(ConcurrencyTest.java:29)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 6 common frames omitted
如果我使用“spring-boot-starter”而不是“spring-boot-starter-web”更新我的pom.xml,我又得到了一个例外
2015-08-19 15:02:06.930 INFO 4528 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.15.2 (CamelContext: concurrent-route-context) started in 1.320 seconds
2015-08-19 15:02:06.932 INFO 4528 --- [ main] c.o.b.c.s.boot.test.ConcurrencyTest : Started ConcurrencyTest in 2.615 seconds (JVM running for 2.867)
Exception in thread "main" 2015-08-19 15:02:06.933 INFO 4528 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@142f024: startup date [Wed Aug 19 15:02:05 CST 2015]; root of context hierarchy
2015-08-19 15:02:06.934 INFO 4528 --- [ Thread-1] o.a.camel.spring.SpringCamelContext : Apache Camel 2.15.2 (CamelContext: concurrent-route-context) is shutting down
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.apache.camel.spring.boot.CamelSpringBootApplicationController] is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:371)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:968)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.testSpringBoot(ConcurrencyTest.java:47)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.main(ConcurrencyTest.java:30)
2015-08-19 15:02:06.937 INFO 4528 --- [ Thread-1] o.a.camel.impl.DefaultShutdownStrategy : Starting to graceful shutdown 4 routes (timeout 300 seconds)
如果我做了任何错误配置,有人会建议吗?
答案 0 :(得分:0)
我不知道您是否已找到解决方案,但请为您的应用程序类尝试:
Printing description of response:
▿ 3 elements
▿ [0] : 2 elements
- .0 : blogs
▿ .1 : 1 elements
▿ [0] : 4 elements
▿ [0] : 2 elements
- .0 : timeline
▿ .1 : 6 elements
▿ [0] : 2 elements
- .0 : post_like
▿ [1] : 2 elements
- .0 : follow
▿ [2] : 2 elements
- .0 : achievement
▿ [3] : 2 elements
- .0 : comment_like
▿ [4] : 2 elements
- .0 : new_comment
▿ [5] : 2 elements
- .0 : mentions
▿ [1] : 2 elements
- .0 : email
▿ .1 : 6 elements
▿ [0] : 2 elements
- .0 : post_like { ... }
▿ [1] : 2 elements
- .0 : follow { ... }
▿ [2] : 2 elements
- .0 : achievement { ... }
▿ [3] : 2 elements
- .0 : comment_like { ... }
▿ [4] : 2 elements
- .0 : new_comment { ... }
▿ [5] : 2 elements
- .0 : mentions { ... }
▿ [2] : 2 elements
- .0 : device
▿ .1 : 7 elements
▿ [0] : 2 elements
- .0 : comment_like { ... }
▿ [1] : 2 elements
- .0 : follow { ... }
▿ [2] : 2 elements
- .0 : device_id
▿ [3] : 2 elements
- .0 : post_like { ... }
▿ [4] : 2 elements
- .0 : achievement { ... }
▿ [5] : 2 elements
- .0 : new_comment { ... }
▿ [6] : 2 elements
- .0 : mentions { ... }
▿ [3] : 2 elements
- .0 : blog_id
▿ [1] : 2 elements
- .0 : other
▿ .1 : 3 elements
▿ [0] : 2 elements
- .0 : email { ... }
▿ .1 : 2 elements
▿ [0] : 2 elements
- .0 : comment_reply
▿ [1] : 2 elements
- .0 : comment_like { ... }
▿ [1] : 2 elements
- .0 : timeline { ... }
▿ .1 : 2 elements
▿ [0] : 2 elements
- .0 : comment_reply { ... }
▿ [1] : 2 elements
- .0 : comment_like { ... }
▿ [2] : 2 elements
- .0 : device { ... }
▿ .1 : 3 elements
▿ [0] : 2 elements
- .0 : comment_reply { ... }
▿ [1] : 2 elements
- .0 : device_id { ... }
▿ [2] : 2 elements
- .0 : comment_like { ... }
▿ [2] : 2 elements
- .0 : wpcom
▿ .1 : 3 elements
▿ [0] : 2 elements
- .0 : marketing
▿ [1] : 2 elements
- .0 : research
▿ [2] : 2 elements
- .0 : community
(lldb)