gpt4 book ai didi

java - 如何让 Eclipse 使用 Gradle 生成 MapStruct Mappers

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:21:24 26 4
gpt4 key购买 nike

是否有任何特殊配置可以让 Eclipse 生成 Mapstruct 映射器?目前它们没有被生成。

它们确实在 gradle 构建中生成,但我无法让它们生成,所以我可以在开发中使用它们。

我将其添加到我的 build.gradle 中:

plugins {
id "net.ltgt.apt" version "0.10"
}
dependencies {
compile "org.mapstruct:mapstruct-jdk8:$mapstructVersion"
apt "org.mapstruct:mapstruct-processor:$mapstructVersion"
}

我还为 MapStruct 添加了 eclipse 插件(虽然我相信这实际上不是必需的???)

然后我转到“项目”>“属性”>“Java 编译器”>“注释处理”:

screenshot

但是 .apt_generated 是空的,我错过了什么?

我正在使用:

Eclipse:版本:Oxygen Release (4.7.0) Build id:20170620-1800

MapStruct 版本 1.2.0.CR1(也尝试 1.1.0.FINAL)

最佳答案

所以经过一番搜索后,我确定解决方案是您必须手动运行 eclipse gradle 中的任务。如果成功,您应该会看到类似以下内容:

enter image description here

解决方案来自阅读 https://github.com/tbroyer/gradle-apt-plugin文档指出:

When using Buildship, you'll have to manually run the eclipseJdtApt and eclipseFactorypath tasks to generate the Eclipse configuration files, then either run the eclipseJdt task or manually enable annotation processing: in the project properties → Java Compiler → Annotation Processing, check Enable Annotation Processing. Note that while all those tasks are depended on by the eclipse task, that one is incompatible with Buildship, so you have to explicitly run the two or three aforementioned tasks and not run the eclipse task.

它指出 eclipse task 与 buildship 不兼容,但这似乎已修复(我运行了 eclipse task 并且没有任何问题):

enter image description here

但是我对 cleanEclipse 确实有问题似乎与 Buildship 不兼容的任务。

毕竟这*MapperImpl.java类在 <project_root>/.apt_generated 中生成

关于java - 如何让 Eclipse 使用 Gradle 生成 MapStruct Mappers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45518161/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com