1

Not sure what happens here but when I do mvn clean install I get following error:

incompatible types: capture#1 of ? cannot be converted to com.sweetchoice.report.entities.WhoDelivers

Mapper class:

@Mapper(uses = {BaseJournalMapper.class})
public interface WhoDeliversMapper {

    WhoDelivers dtoToEntity(WhoDeliversDto whoDeliversDto);

    WhoDeliversDto entityToDto(WhoDelivers whoDelivers);
}

Entity class:

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "who_delivers")
public class WhoDelivers extends BaseJournalEntity{

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(columnDefinition = "serial")
    private Long id;

    private String name;
}

BaseJournalEntity/BaseJournalDto:

@Getter
@Setter
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@MappedSuperclass
public class BaseJournalDto {

    private LocalDateTime createdAt;
    private Long createdBy;
    private LocalDateTime updatedAt;
    private Long updatedBy;
}

DTO class:

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class WhoDeliversDto extends BaseJournalDto{

    private Long id;

    private String name;

}

and finally pom.xml:

     <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${mapstruct.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${mapstruct.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId> lombok-mapstruct-binding</artifactId>
                            <version>0.1.0</version>
                        </path>
                    </annotationProcessorPaths>
                    <compilerArgs>
                        <compilerArg>-Amapstruct.defaultComponentModel=spring</compilerArg>
                    </compilerArgs>
                </configuration>
            </plugin>
enter code here

I'm using Java 11, MapStruct 1.4.1.Final and Lombok 1.18.16

1 Answer 1

3

Answer :

Found an answer on my own.

Just add @SuperBuilder in Entity and DTO classes. More info on this link Documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.