這是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>
我用@Mapper. 當我檢查目標檔案夾時,映射器實作不存在。奇怪的是,當我使用 IntelliJ 的構建功能進行編譯時,會生成類,我可以在目標檔案夾下看到它們。但是當我編譯 usingmvn clean package或只mvn package生成類時。什么會導致這種情況?
uj5u.com熱心網友回復:
我唯一能想到的是,我第一次使用 mapstruct 時忘??記了類需要是介面,這是我使用 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 );
}
我查看了你的 pom.xml,我沒有發現它有什么問題,所以我認為這不是問題,祝你好運!
uj5u.com熱心網友回復:
感謝 GitHub- issue link上的一位用戶,我解決了這個問題。問題在于源和目標標簽中的 1. 前綴。所以我洗掉了它:
<source>17</source> <!-- depending on your project -->
<target>17</target> <!-- depending on your project -->
<release>17</release>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/352788.html
