Skip to content

Latest commit

 

History

History
70 lines (44 loc) · 1.85 KB

README.adoc

File metadata and controls

70 lines (44 loc) · 1.85 KB

Camel Example MapStruct

This example shows how to use MapStruct with Camel.

MapStruct is a powerful Java bean mapping code generator.

How to use MapStruct

  1. This example generates POJO classes from sample JSon data located in src/main/resources/documents. We use the jsonschema2pojo-maven-plugin Maven plugin (see details in pom.xml).

  2. Then we have installed MapStruct as a Java compiler plugin (see details in pom.xml).

  3. We declared the MapStruct mapping in the BeerMapper Java interface.

  4. We configured camel-mapstruct to load the mappings by package scanning (see details in application.properties)

Build

First compile the example by executing:

$ mvn compile

How to run

Then you can run this example using

$ mvn camel:run

And then send an HTTP POST request to Camel which will do a JSON to JSON mapping via MapStruct.

curl -s -X POST -H "Content-Type: application/json" -d @src/main/resources/documents/beer.json http://localhost:8080/beer
Note
The sample data are from https://random-data-api.com/api/beer/random_beer

How to configure for Camel Textual Route debugging

Several IDEs are providing support for Camel Textual Route debugging. To enable this possibility, you need to launch this example with the profile camel.debug.

$ mvn camel:run -Pcamel.debug

This profile can also be activated with camel.debug property set to true. For instance, by setting the property from command-line:

$ mvn camel:run -Dcamel.debug=true

Help and contributions

If you hit any problem using Camel or have some feedback, then please let us know.

We also love contributors, so get involved :-)

The Camel riders!