简体   繁体   English

如何在可执行文件 jar 中运行 lombok 功能?

[英]How can I run lombok features in my executable jar file?

Consider I have a constructor of more that 10 or more args, and I am using it in criteria select query to fetch data.假设我有一个包含 10 个或更多参数的构造函数,并且我在条件 select 查询中使用它来获取数据。 Now the problem is that I want to remove my constructor as it gives me sonar issues.现在的问题是我想删除我的构造函数,因为它给我带来了声纳问题。

So I tried to Lombok dependency, @AllArgsConstructor it is working in my IDE, but when I create the jar file it is not being used by JPA query.所以我尝试了 Lombok 依赖项, @AllArgsConstructor它在我的 IDE 中工作,但是当我创建 jar 文件时,它没有被 JPA 查询使用。

I need help either to make lombok work in my project.jar file,我需要帮助才能使 lombok 在我的project.jar文件中工作,

OR要么

change in select query which does not use constructor,更改不使用构造函数的 select 查询,

OR要么

Any other better way任何其他更好的方法

Lombok is a compile-time affair. Lombok 是一个编译时事件。 Once your code is compiled (you have class files), lombok shouldn't be there / wouldn't be doing anything.一旦你的代码被编译(你有 class 个文件),lombok 不应该在那里/不会做任何事情。 Lombok is not a library in that sense.从这个意义上说,龙目岛不是图书馆。 You don't ship 'javac' with your app either.您也不会将“javac”与您的应用程序一起发布。

If lombok is part of the compilation, then lombok will do its thing.如果 lombok 是编译的一部分,那么 lombok 就会做它的事情。 If it's not, then your compiler would generate an error;如果不是,那么您的编译器会产生错误; after all, it wouldn't know what @AllArgsConstructor is about.毕竟,它不知道@AllArgsConstructor是关于什么的。 So, if you're not observing any compilation errors, lombok did its thing*.所以,如果你没有观察到任何编译错误,那么 lombok 就做了它的事情*。

Secondly, sonar is a linting tool.其次,sonar 是一种 linting 工具。 It's there to help you out.它可以帮助您。 If it is 'telling you off' for writing code where you think it is the best way to do it, then tell sonar to stop complaining about it.如果在您认为这是最好的方法的地方编写代码是“让您失望”,那么请告诉声纳停止抱怨它。 It's a tool for you to use;它是供您使用的工具; not a prison.不是监狱。

You can use javap to check if the all-args constructor is there.您可以使用javap检查是否存在全参数构造函数。 If it is (it should be), then your question is actually: How do I make my JPA tooling use that constructor?如果是(应该是),那么您的问题实际上是:如何让我的 JPA 工具使用该构造函数?

*) It is possible, but takes some work, to tell javac to have lombok's classes available, but NOT to run it as an annotation processor. *) 有可能,但需要一些工作,告诉 javac 有可用的 lombok 类,但不要将其作为注释处理器运行。 But if you do manage that, then lombok wouldn't have transformed any of your classes.但是,如果您确实做到了这一点,那么 lombok 就不会改变您的任何课程。 I assume that's not the case, as you need to go out of your way with lots of command line switches to make this happen.我认为情况并非如此,因为您需要 go 使用大量命令行开关来实现这一目标。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使我的可执行JAR不需要JDK运行 - How can I make my executable JAR not need JDK to run 如何在R脚本中运行可执行的.jar文件? - How can I run an executable .jar file in an R script? 如何将Java程序作为可执行的.jar文件运行? - How to run my a Java program as an executable .jar file? 如何导出带有Eclipse库的jar文件? (不是可执行的jar) - How can i export a jar file with libraries in eclipse? (Not executable jar) 如何在没有命令提示符的情况下运行可执行文件.jar? - How can an executable .jar file be run without the command prompt? 当我的班级和文本文件位于可执行JAR中时,如何编写代码访问文本文件? - How can I write code to access a text file when my class and the text file are in an Executable JAR? 我如何从我的java .jar文件创建可执行的apple .app文件? - How can i create executable apple .app file from my java .jar file? 将测试导出到可执行jar时如何在可执行Jar文件中包含Chrome驱动程序 - How to include Chrome Driver in executable Jar file when I export my tests to a Executable jar 如何增加应用程序可执行jar文件中的JVM堆大小? 项目类型为Maven Project - How can I increase JVM heap size in my application executable jar file? The project type is Maven Project 在创建可执行 jar 时,如何引用本地文件并将其包含在我的 Maven 程序集中? - how can I reference a local file and include it with my maven assembly when creating an executable jar?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM