Software Development

Spring Boot – Using annotations with Apache Camel

This post demonstrates how to use Spring Boot, and Spring DI with Apache Camel and have Spring add routes and start and stop CamelContext automatically.

The Spring way

In the previous post, Spring Boot – Copy File to Another Directory using Apache Camel, I created a Spring Boot application that rely only on the static main method.


The only “Spring” codes there is the use of SpringApplication and retrieval of “camelContext” bean from the ApplicationContext

Let’s rewrite those codes by creating a new Spring Boot application that uses @Configuration, and @Bean (or @Component).

New Spring Boot Application

Our new Spring Boot application has a leaner main class.


Then, create a @Configuration class and @Bean object.


That’s it!

Just drop files to the in directory and Apache Camel will copy them to the out directory.

Testing the new Spring Boot Application

Download the Codes


Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like