Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mapstruct v1.3.1FINAL: imports from static methods aren't generated

Tags:

java

mapstruct

We are using mapstruct 1.3.1FINAL (in combination with lombok v1.18.4 if that matters) and the generated classes aren't compiling because the imports of the static methods used in expression mappings aren't generated. Any clues?

@Mapping(target = "value", expression = "java(ValueUtil.getValue(sourceValue))")

The generated code has compilation errors because the import of ValueUtil is missing :

request.setValue( ValueUtil.getValue(sourceValue) );
like image 710
Bernado Avatar asked Oct 31 '25 18:10

Bernado


2 Answers

Finally i got it, tried out what Sjaak wrote.

@Mapper(imports = { ValueUtil.class })

The import made it. Will try out if Deepaks answer works as well.

like image 102
Bernado Avatar answered Nov 03 '25 10:11

Bernado


Please try with fully qualified class name for ValueUtil I.e. packagename.ValueUtil. This will provide the context to mapstruct to locate the class.

like image 39
Deepak Muthekar Avatar answered Nov 03 '25 08:11

Deepak Muthekar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!