0

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

https://github.com/Turreta/Spring-Boot-Using-annotations-with-Apache-Camel