camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Pimlott (JIRA)" <>
Subject [jira] [Commented] (CAMEL-8801) CamelContext auto-configuration should be conditional
Date Wed, 27 May 2015 19:45:17 GMT


Chris Pimlott commented on CAMEL-8801:

I'm using a simple FarJarRouter subclass that pulls in a Spring XML context containing a camelContext

@ImportResource(value = "classpath:META-INF/spring/camelContext.xml")
public class CamelApplication extends FatJarRouter {


This gives an exception on startup due to there being two {{CamelContext}}s defined:


org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type
[org.apache.camel.CamelContext] is defined: expected single matching bean but found 2: camelContext,transferAndNotify
	at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(
	at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(
	at org.springframework.boot.SpringApplication.refresh(
	at org.apache.camel.spring.boot.FatJarRouter.main(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.springframework.boot.maven.RunMojo$

> CamelContext auto-configuration should be conditional
> -----------------------------------------------------
>                 Key: CAMEL-8801
>                 URL:
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-spring-boot
>    Affects Versions: 2.15.2
>            Reporter: Chris Pimlott
> The {{@Bean}} declaration of {{CamelContext}} within {{CamelAutoConfiguration}} should
be made conditional to allow the user to create it manually if they so desire.  This is useful
when converting an application using an existing XML-based camelContext, for example.
> This would also make camel-spring-boot more consistent with [Spring Boot's policy of
non-invasive auto-configuration|].
> The fix is just to add a conditional annotation on the camelContext method, e.g.:
> {code}
>     @Bean
>     @ConditionalOnMissingBean(CamelContext.class)
>     CamelContext camelContext(ApplicationContext applicationContext,
>                               CamelConfigurationProperties configurationProperties) {
> {code}

This message was sent by Atlassian JIRA

View raw message