This example shows how to use MapStruct with Camel.
MapStruct is a powerful Java bean mapping code generator.
-
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
). -
Then we have installed MapStruct as a Java compiler plugin (see details in
pom.xml
). -
We declared the MapStruct mapping in the
BeerMapper
Java interface. -
We configured camel-mapstruct to load the mappings by package scanning (see details in
application.properties
)
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 |
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
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!