Search code examples
javaeclipsemaven-pluginlombokmapstruct

Mapstrut/Lombok: No property named "customfields" exists in source parameter(s) as on Dec 31 2019


I have seen various posts as well as Lombok Github account where issue related to mapping property not found are in closed state.

But i am getting issue in my use case:

POM.XML

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>1.18.10</version>
                        </path>   

                    </annotationProcessorPaths>
                </configuration>
            </plugin>

Interface

@Mapping(source = "customfields", target = "customfields", ignore = true)
List<License> jsonToDao(List<com.integrator.snow.vo.license.License> source);

Error:

    [ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/EvryIntegrator/Projects/Snow/src/main/java/com/integrator/snow/util/LicenseMapper.java:[13,9] No property named "customfields" exists in source parameter(s). Did you mean "empty"?

As per various stack overflow posts, the pom seems correct. Why i am still getting issue when property exists? (Using eclipse 2019)


Solution

  • When using @Mapping then the source and target are applied to the actual data being mapped. In your case MapStruct is looking for a property named customFields in java.util.List.

    Try this

    List<License> jsonToDao(List<com.integrator.snow.vo.license.License> source);
    
    @Mapping(source = "customfields", target = "customfields", ignore = true)
    License map(com.integrator.snow.vo.license.License source);