Software Development, Spring Boot

Spring Boot – Using annotations with Apache Camel

This post shows how to use Spring Boot and dependency injection with Apache Camel and have Spring add routes and start and stop CamelContext automatically.

The Spring way for Apache Camel

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

The only “Spring” codes there are 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!

Drop files in the directory, and Apache Camel will copy them to the out directory.

Testing the new Spring Boot Application

Download the Codes

The codes are available on this GitHub repository.


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