Hi, currently I am setting up a new project using Spring and Camel. For a change, I wanted to use JavaConfig instead of the XML and had little problem injecting a ProducerTemplate. I am aiming for ConstructorBasedInjection, and @EndpointInject did not work for me. What I ended up doing is the following:
@Configuration @PropertySource("classpath:foo.properties") @EnableJpaRepositories(basePackages = "x.y.foo.repository") @EnableTransactionManagement @ComponentScan(basePackages = { "x.y.foo.service", "x.y.foo.camel" }) public class ApplicationContext extends CamelConfiguration { .... @Bean(destroyMethod = "stop") public ProducerTemplate producerTemplate() throws Exception{ return camelContext().createProducerTemplate(); } ... } This way I can use @Autowired to inject a producerTemplate: @Service public class FooServiceImpl implements FooService { private final ProducerTemplate producerTemplate; @Autowired public QuoteServiceImpl(ProducerTemplate producerTemplate) { Assert.notNull(producerTemplate, "producerTemplate must not be null."); this.producerTemplate = producerTemplate; } ... } Is this approach acceptable or is there a better way? Regards, Tom