Search code examples
javaintellij-ideadtomapstructmapper

Mapstruct "Can't find related attribute"


I have this Mapper class. I'm trying to combine all three objects into a single Dto for the view to use the Dto object:

@Mapping(source = "childSeat.id", target = "childSeatId")
@Mapping(source = "childSeatCol.id", target = "childSeatColId")
@Mapping(source = "dummyCollision.id", target = "dummyCollisionId")
ListeDePositionsUniquesDto toDTO(ChildSeat childSeat, ChildSeatCol childSeatCol, DummyCollision dummyCollision);

Here is a screenshot from the IDE: Ide screenshot When I hover the source error it says: Can't find related attribute

Here are my dependencies:

<!-- MapStruct + Lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${org.projectlombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${org.mapstruct.version}</version>
        </dependency>
...
    <build>
       ...
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${org.projectlombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                        <!-- other annotation processors -->
                        <!-- additional annotation processor required as of Lombok 1.18.16 -->
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok-mapstruct-binding</artifactId>
                            <version>0.2.0</version>
                        </path>
                    </annotationProcessorPaths>
                ...
    </build>

I'm using Java 1.8, IntelliJ IDEA Ultimate.


Solution

  • The installation of Mapstruct Support plugin, which provides code completion and other features for projects that use Mapstruct, was the solution in my case.