Lombok + JPA:是否可以生成规范元模型?

3
  • I'm using Project Lombok, a (spurious) JSR 269 implementation providing useful features like the generation of getters and setters at compile time while keeping the source code clean:

    @Getter @Setter private String foo;
    
  • I'd like to use another annotation processor (a JSR 269 implementation like hibernate-jpamodelgen) to generate the JPA Canonical Metamodel (JSR 317), but no matter how hard I try (Maven, Eclipse, etc...) it does seem that there is no way to instruct it to start reading the entities from the generated code, instead that from the source (that, being not yet interpreted by Lombok, does not even compile).

有没有一种方法可以以所需的方式将这两个注释处理器连接起来?

2
我认为这个问题与同样的问题有关(注解处理器的排序)。 - Tunaki
您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - Tunaki
@Tunaki 我认为这个问题不是那个的重复。我可以为这个问题提供一个解决方案:在实体类中添加@Access(AccessType.FIELD)注释。但这对于那个问题来说并不适用。 - Tarwirdur Turon
2
这篇文章提供的解决方案对我很有用: https://dev59.com/jqLia4cB1Zd3GeqPmqvD - N Dierauf
感谢您在这里发表评论,@NDierauf! - Andrea Ligios
1个回答

2
您可能能够配置您的构建,先在源文件上运行 delombok,然后再编译其余部分。
披露:我是 lombok 的开发者。

谢谢。您能详细介绍一下它的用法吗?至少对于Maven插件来说,似乎我应该将所有带有Lombok注释的Java文件从src/main/java移动到src/main/lombok,但我仍然不确定第二个注释处理器应该如何以及为什么应该找到delomboked文件,因为我的实体(从中生成元模型)Lombok注释的,因此会在src/main/lombok中。看起来,将Lombok文件与其他AP分开并使其在非Lombok文件上工作可能有效,但对于带有Lombok注释的文件是否有效呢?如果我表述不够清楚,请见谅。 - Andrea Ligios
您不需要将Lombok文件与非Lombok文件分开。Delombok也可以处理非Lombok文件。我本人对maven插件不熟悉,但默认情况下可能会处理“src/main/lombok”目录,但我认为这是可配置的。 - Roel Spilker

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接