Here's to pom.xml:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.17</source> <!-- depending on your project -->
<target>1.17</target> <!-- depending on your project -->
<release>17</release>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</path>
<!-- other annotation processors -->
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
I have annotated my classes with @Mapper
. When I examine the target folder, the mapper implementations are not there. The weird part is, when I compile using IntelliJ's build functionality, the classes are generated and I can see them under the target folder. But when I compile using mvn clean package
or just mvn package
the classes are not generated. What can cause this?
CodePudding user response:
Only thing I can think of, that slipped my mind the first time I used mapstruct is the classes need to be interfaces, this is a sample class I have that uses mapstruct:
import org.mapstruct.Mapper;
import org.mapstruct.factory.*;
@Mapper
public interface BeaconMapper {
public BeaconMapper INSTANCE = Mappers.getMapper( BeaconMapper.class );
public BeaconDTO BeaconToBeaconDTO( Beacon beacon );
public Beacon BeaconDTOToBeacon( BeaconDTO beaconDTO );
}
I reviewed your pom.xml and I don't see anything wrong with it, so I don't think that is the issue, good luck!
CodePudding user response:
I solved the issue thanks to a user over at GitHub - issue link. The problem was with the 1. prefix in the source and target tags. So I removed it:
<source>17</source> <!-- depending on your project -->
<target>17</target> <!-- depending on your project -->
<release>17</release>