Java Bean Mapping with MapStruct

MapStruct is a nice tool to generate mappers for converting one Java bean into another e.g. for projections, data-transfer-objects and so on …​ As long as fields in source and target beans do match, the mapper is able to generate the data setting automatically .. else we may specify which source fields to map into which target fields or to register custom converters with ease. Using Maven, we need to add dependencies and plugin integration to our pom.xml: ...

March 31, 2022 · 3 min · 459 words · Micha Kops

Snippet: Java 9 Modules and JPMS

Playing around with the new module system in Java 9 I simply wanted to write down how to achieve the most basic tasks. Therefore I created the following module how-to based upon a simple demonstration project consisting of two dependant modules. Figure 1. Modules Component-Diagram Prerequisites and Setup We need an early access build of the Java ™ 9 JDK, available for download here. In addition we should make sure, that our environment variable JAVA_HOME is set to the corresponding directory and calling java -version returns something similar to this: ...

April 17, 2017 · 6 min · 1240 words · Micha Kops

Maven Snippets

Extract Coordinates from the POM Helpful for build and integration environments, pipelines etc. Exctract the Project version from the pom.xml mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout Override a Property via local configuration e.g. to override the property xxx from your project’s pom.xml Create a directory .mvn in your project directory root Create a file named maven.config in this directory Insert -Dxxx=newvalue into the file to override this property Don’t forget to add .mvn to your .gitignore! ...

March 1, 2010 · 2 min · 401 words · Micha Kops