Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added fat jars/wars section.

...

Code Block
xml
xml
camel.springboot.typeConversion = false

Fat jars and fat wars

The easiest way to create Camel-aware Spring Boot fat jar/war is to extend the org.apache.camel.spring.boot.FatJarRouter class...

 

Code Block
languagejava
package com.example;
 
... // imports
 
@SpringBootApplication
public class MyFatJarRouter extends FatJarRouter {

    @Override
    public void configure() throws Exception {
        from("netty-http:http://0.0.0.0:18080").
            setBody().simple("ref:helloWorld");
    }

    @Bean
    String helloWorld() {
        return "helloWorld";
    }

}

 

...and add the following property to your application.properties file:

 

Code Block
xml
xml
spring.main.sources = com.example.MyFatJarRouter

It is also recommended to define your main class explicitly in the Spring Boot Maven plugin configuration: 

Code Block
xml
xml
 <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${spring-boot.version}</version>
    <configuration>
      <mainClass>com.example.MyFatJarRouter</mainClass>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>repackage</goal>
        </goals>
      </execution>
    </executions>
</plugin>

In order to turn your fat jar into fat war, add the following class extending  org.apache.camel.spring.boot.FatWarInitializer to your project:

Code Block
languagejava
package com.example;
 
... // imports

public class MyFatWarInitializer extends FatWarInitializer {


  @Override
  protected Class<? extends FatJarRouter> routerClass() {
    return MyFatJarRouter.class;
  }

}


Include Page
Endpoint See Also
Endpoint See Also