目前,对于在 eclipse 中使用 mapstruct 的每个项目,我必须:
Configure Build Path > Java Compiler > Annotation Processing > Factory Path
并选中“使用项目特定设置”并配置工厂路径以每次手动使用mapstruct处理器jar。
短语“使用项目特定设置”有点暗示某处的全局设置,但我无法在“首选项”下找到类似的内容。
是否有地方可以配置注释处理的默认行为?
最佳答案
我遵循了 Filip 的建议,但是一旦将项目导入到 Eclipse 工作区中,我就无法让 Eclipse 添加必要的类路径。我在 pom.xml 中添加了 build-helper-maven-plugin 以帮助 Eclipse 添加所需的类路径:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/annotations/</source>
</sources>
</configuration>
</execution>
</executions>
这会在 .classpath 文件中生成所需的类路径条目:
<classpathentry kind="src" output="target/classes" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
关于java - 在Eclipse中,是否可以默认设置注释处理和工厂路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46947990/