【发布时间】:2017-01-23 07:39:37
【问题描述】:
我收到一个编译错误:
com/mycompany/hibernate5/Main.java:[10,46] cannot find symbol
symbol: class Customer_
location: package com.mycompany.hibernate5.sakila.domain
com/mycompany/hibernate5/Main.java:[11,46] cannot find symbol
symbol: class Address_
location: package com.mycompany.hibernate5.sakila.domain
2 errors
但是,当我删除 mapstruct 注释处理器时,它编译得很好。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<!-- <configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>-->
</plugin>
所以我认为 mapstruct 是在生成类之前对其进行扫描?有什么解决办法吗?
【问题讨论】:
-
如何添加元模型生成器?您是否通过
annotationProcessorPaths添加了元模型生成器和 MapStruct? -
为什么mapstruct要手动添加annotationProcessorPath? “如果省略,则使用默认类路径来检测注释处理器。”为什么默认类路径不像 JPA metamodelgen 那样选择它?
-
两种方法都应该有效:将两个处理器添加到(可选)项目依赖项或通过 annotationProcessorPaths 添加它们。我会推荐后者。
-
我的意思是,如果您将 annotationProcessorPaths 留空,它不应该扫描所有 jar 并拾取 mapstruct 和 hibernate 元模型 annontaion 处理器吗?
-
是的,这也应该可以。
标签: mapstruct