mapstruct - Mapstruct 没有为我的映射器接口之一生成实现。有没有办法知道原因?
问题描述
我正在使用 mapstruct 从/到域对象映射到 DTO 我有 20 多个正在正确生成的映射器。
我的一个映射器不再生成,但编译成功。我使用 maven 并showWarnings
在配置中打开了标志maven-compiler-plugin
,但是我没有看到有关该特定映射器的警告(我确实看到了其他映射器的警告)。
有没有办法从注释处理器中获取一些关于未生成的映射器的信息?
我的映射器界面(名称更改):
@Mapper
public interface PersonMapper {
PersonMapper INSTANCE = Mappers.getMapper(PersonMapper.class);
PersonDTO map(Person entity);
Person map(PersonDTO dto);
}
我的 Maven 配置:
...
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>1.3.0.Final</version>
</dependency>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
...
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.3.0.Final</version>
</path>
</annotationProcessorPaths>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
解决方案
For me it was a dependency issue.
My Projet A, had a dependency to another jar B, which contained the object from my mapper method. That dependency B had a dependency C offering mapstruct mapper for many of the attribut of the object.
Somehow in my project A i was overriding explicitly the version of dependency C to an older version. So it means that some of the Obj attribute from current B version where not matching with the older C mapper. Mapstruct said nothing, just stopped generating the impl.
Not sure if this is very clear ... But check your dependencies.
推荐阅读
- javascript - TypeError:person.map 不是函数
- google-colaboratory - IBM Cloud Watson (NLU) 情感服务错误
- python - 错误消息:无法从 'pylab 导入名称'hold'
- android - Android 芯片:如何更改文本垂直填充?
- c# - 当您拥有相关实体的 ID 时如何映射相关实体的属性
- vert.x - 如何更改 quarkus-vertx eventBus ClusterManager 选项
- android - 更新 gradle 错误我在添加库并更新时遇到问题
- azure - 在子路径上部署服务而不在 Kubernetes 中重定向
- c# - 带 alpha 的混合模式
- matlab - 循环问题Matlab CVX的问题效率低下