Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 4. Develop an Application for the Spring Boot Image

4.1. Overview

This chapter explains how to develop applications for the Spring Boot image.

4.2. Create a Spring Boot Project using Maven Archetype

To create a Spring Boot project, follow these steps:

  1. Go to the appropriate directory on your system.
  2. Launch the mvn command to create Spring Boot project

    mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate \
      -DarchetypeCatalog= \
      -DarchetypeGroupId=org.jboss.fuse.fis.archetypes \
      -DarchetypeArtifactId=spring-boot-camel-xml-archetype \

    The archetype plug-in switches to interactive mode to prompt you for the remaining fields

    Define value for property 'groupId': : org.example.fis
    Define value for property 'artifactId': : fis-spring-boot
    Define value for property 'version':  1.0-SNAPSHOT: :
    Define value for property 'package':  org.example.fis: :
    [INFO] Using property: spring-boot-version = 1.4.1.RELEASE
    Confirm properties configuration:
    groupId: org.example.fis
    artifactId: fis-spring-boot
    version: 1.0-SNAPSHOT
    package: org.example.fis
    spring-boot-version: 1.4.1.RELEASE
     Y: :

    When prompted, enter org.example.fis for the groupId value and fis-spring-boot for the artifactId value. Accept the defaults for the remaining fields.

Then, follow the instructions in the quickstart on how to build and deploy the example.


For the full list of available Spring Boot archetypes, see Section 4.4, “Spring Boot Archetype Catalog”.

4.3. Structure of the Camel Spring Boot Application

The directory structure of a Camel Spring Boot application is as follows:

  ├── pom.xml
  └── src
      ├── main
      │   ├── fabric8
      │   │   └── deployment.yml
      │   ├── java
      │   │   └── org
      │   │       └── first1
      │   │           └── spring
      │   │               └── boot
      │   │                   └── project
      │   │                       ├──
      │   │                       └──
      │   └── resources
      │       ├──
      │       ├── logback.xml
      │       └── spring
      │           └── camel-context.xml
      └── test
          ├── java
          │   └── org
          │       └── first1
          │           └── spring
          │               └── boot
          │                   └── project
          │                       └──
          └── resources

Where the following files are important for developing an application:

Includes additional dependencies. Camel components that are compatible with Spring Boot are available in the starter version, for example camel-jdbc-starter or camel-infinispan-starter. Once the starters are included in the pom.xml they are automatically configured and registered with the Camel content at boot time. Users can configure the properties of the components using the file.

It is an important file that allows you to externalize your configuration and work with the same application code in different environments. For details, see Externalized Configuration

For example, in this Camel application you can configure certain properties such as name of the application or the IP addresses, and so on.

# the options from org.apache.camel.spring.boot.CamelConfigurationProperties can be configured here

# lets listen on all ports to ensure we can be invoked from the pod IP

It is an important file to run your application. As a user you will import here a file camel-context.xml to configure routes using the Spring DSL.

The file specifies the @SpringBootApplication annotation, which is equivalent to @Configuration, @EnableAutoConfiguration and @ComponentScan with their default attributes.

// load regular Spring XML file from the classpath that contains the Camel XML DSL

It must have a main method to run the Spring Boot application.

public class Application {
     * A main method to start this application.
    public static void main(String[] args) {, args);


The src/main/resources/spring/camel-context.xml is an important file for developing application as it contains the Camel routes.


You can find more information on developing Spring-Boot applications at Developing your first Spring Boot Application


Provides additional configuration that is merged with the default OpenShift configuration file generated by the fabric8-maven-plugin.


This file is not used part of Spring Boot application but it is used in all quickstarts to limit the resources such as CPU and memory usage.
An Arquillian based integration test that test deploying into OpenShift and making sure the container can boot correctly.

4.4. Spring Boot Archetype Catalog

The Spring Boot Archetype catalog includes the following examples.

Table 4.1. Spring Boot Maven Archetypes



Demonstrates how to use Apache Camel with Spring Boot based on a fabric8 Java base image.


Demonstrates how to connect a Spring-Boot application to an ActiveMQ broker and use JMS messaging between two Camel routes using Kubernetes or OpenShift.


Demonstrates how to configure a Spring-Boot application using Kubernetes ConfigMaps and Secrets.


Demonstrates how to use Apache Camel to integrate a Spring-Boot application running on Kubernetes or OpenShift with a remote Kie Server.


Demonstrates how to connect a Spring-Boot application to a JBoss Data Grid or Infinispan server using the Hot Rod protocol.


Demonstrates how to use SQL via JDBC along with Camel’s REST DSL to expose a RESTful API.


Demonstrates how to connect Apache Camel to a remote JBoss Data Virtualization (or Teiid) Server using the JDBC protocol.


Demonstrates how to configure Camel routes in Spring Boot via a Spring XML configuration file.


Demonstrates how to use Apache CXF with Spring Boot based on a fabric8 Java base image. The quickstart uses Spring Boot to configure an application that includes a CXF JAXRS endpoint with Swagger enabled.


Demonstrates how to use Apache CXF with Spring Bootbased on a fabric8 Java base image. The quickstart uses Spring Boot to configure an application that includes a CXF JAXWS endpoint.

4.5. Camel Starter Modules

4.5.1. Overview

Starters are Apache Camel modules intended to be used in Spring Boot applications. There is a camel-xxx-starter module for each Camel component (with few exceptions listed below).

Starters meet the following requirements:

  • Allow auto-configuration of the component using native Spring Boot configuration system which is compatible with IDE tooling.
  • Allows auto-configuration of data formats and languages.
  • Manage transitive logging dependencies to integrate with Spring Boot logging system.
  • Include additional dependencies and align transitive dependencies to minimize the effort of creating a working Spring Boot application.

Each starter has its own integration test in tests/camel-itest-spring-boot, that verifies the compatibility with the current release of Spring Boot.

4.5.2. Using Camel Starter Modules

Apache Camel provides a starter module that allows you to develop Spring Boot applications using starters.

To use the Spring Boot starter:

  1. Add the following to your Spring Boot pom.xml file:

  2. Add classes with your Camel routes such as:

    package com.example;
    import org.apache.camel.builder.RouteBuilder;
    import org.springframework.stereotype.Component;
    public class MyRoute extends RouteBuilder {
        public void configure() throws Exception {

These routes will be started automatically.


To keep the main thread blocked so that Camel stays up, either include the spring-boot-starter-web dependency, or add camel.springboot.main-run-controller=true to your or application.yml file.

You can customize the Camel application in the or application.yml file with camel.springboot.* properties.

4.6. Unsupported Starter Modules

The following components do not have a starter because of compatibility issues:

  • camel-blueprint (intended for OSGi only)
  • camel-cdi (intended for CDI only)
  • camel-core-osgi (intended for OSGi only)
  • camel-ejb (intended for JEE only)
  • camel-eventadmin (intended for OSGi only)
  • camel-ibatis (camel-mybatis-starter is included)
  • camel-jclouds
  • camel-mina (camel-mina2-starter is included)
  • camel-paxlogging (intended for OSGi only)
  • camel-quartz (camel-quartz2-starter is included)
  • camel-spark-rest
  • camel-swagger (camel-swagger-java-starter is included)