Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Spring Java Config Example

Info
titleSimple Jar runner

Want to run your jar file and supply a list of packages / configuration classes and just see it run with Camel? Try Main from org.apache.camel.spring which even supports command-line flags.

The spring java config example is a simple refactor of the spring example since Camel 2.0 to show how to use the Spring JavaConfig approach to working with Camel. In this example we just write RouteBuilder implementations, then Camel will find it through your configuration.

 

NOTE From Camel 2.2.0, camel-example-spring-javaconfig can only work with Spring 3.x.

To run the example we use the Camel Maven Plugin. For example from the source or binary distribution the following should work

Code Block

cd examples/camel-example-spring-javaconfig
mvn camel:run

You need to add camel-spring-javaconfig dependency into pom.xml and also set the configure class or base package in the camel plugin configuration.

Code Block

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring-javaconfig</artifactId>
    </dependency>

...