Lombok

IntelliJ IDEA cannot see Lombok generated code

蹲街弑〆低调 提交于 2019-12-03 05:25:57
问题 I have a Gradle-based project that uses lombok. I have imported this project into IntelliJ IDEA 14.1 (using the Import External Model import method). I can run the JUnit4 unit tests without problem in Gradle, but IntelliJ seems to have a problem seeing the Lombok generated Getters. This is preventing me from running the tests in IDEA. To make sure it wasn't a set up issue, I created a Very simple project and confirmed that the same issue occurs in the simple test project. My versions: Gradle:

Java Lombok: Omitting one field in @AllArgsConstructor?

ε祈祈猫儿з 提交于 2019-12-03 05:13:02
If I specify @AllArgsConstructor using Lombok , it will generate a constructor for setting all the declared (not final, not static) fields. Is it possible to omit some field and this leave generated constructor for all other fields? No that is not possible. There is a feature request to create a @SomeArgsConstructor where you can specify a list of involved fields. Full disclosure: I am one of the core Project Lombok developers. Alternatively you could use @RequiredArgsConstructor . This adds a constructor for all fields that are either @NonNull or final . See documentation A good way to go

Spring实践--@ControllerAdvice 全局处理异常 

本秂侑毒 提交于 2019-12-03 04:53:18
零、前言 对于与数据库相关的 Spring MVC 项目,我们通常会把 事务 配置在 Service层,当数据库操作失败时让 Service 层抛出运行时异常,Spring 事物管理器就会进行回滚。 如此一来,我们的 Controller 层就不得不进行 try-catch Service 层的异常,否则会返回一些不友好的错误信息到客户端。但是,Controller 层每个方法体都写一些模板化的 try-catch 的代码,很难看也难维护,特别是还需要对 Service 层的不同异常进行不同处理的时候。例如以下 Controller 方法代码(非常难看且冗余): /** * 手动处理 Service 层异常和数据校验异常的示例 * @param dog * @param errors * @return */ @PostMapping(value = "") AppResponse add(@Validated(Add.class) @RequestBody Dog dog, Errors errors){ AppResponse resp = new AppResponse(); try { // 数据校验 BSUtil.controllerValidate(errors); // 执行业务 Dog newDog = dogService.save(dog); // 返回数据

Lombok does not work for Eclipse Neon

半腔热情 提交于 2019-12-03 04:47:46
I downloaded lombok.jar (lombok-1.16.14.jar) put it into my Downloads. Then I clicked on this jar, the execution correctly identifies the Eclipse instances on my MacOS and then I selected the instance I want. Lombok is also specified in the pom.xml org.projectlombok lombok 1.16.14 provided In eclipse.ini I got the addition: -javaagent:../Eclipse/lombok.jar lombok.jar was added to the same directory as eclise.ini /Applications/Eclipse.app/Contents/Eclipse I am still getting setter/getter errors in Eclipse Problems despite that my mvn build works fine. The code for a User: @Entity @Getter

What are the risks with Project Lombok?

久未见 提交于 2019-12-03 04:17:05
I'm coming up with performance goals for the new year, and I thought I'd be fun to put a goal to reduce the size of the code base, especially boilerplate. One action I've come up with to address this is to use Project Lombok to make beans as short as they should be. But I have a habit of overlooking downsides to new software and approaches, so I'm relying on the Stack Overflow community: Can anyone tell me why Lombok is a bad idea? Zeki A major downside is IDE support. Since Lombok is not actually a language change, and since your IDE only understands java, you will need an IDE that supports

使用线程池+内存队列实现异步处理业务问题

。_饼干妹妹 提交于 2019-12-03 02:43:45
背景 当系统中的业务存在大量的相同任务(比如发送大量邮件),并且每个任务花费的时间也比较长,前端需要较快 的响应,针对这种需求,我们可以采用消息队列进行异步通知,同时也可以采用线程池+内存队列实现异步通知,处理业务问题。 代码实现 以下采用发送邮件作为demo 邮箱实体类 @Data public class Email implements Serializable { private static final long serialVersionUID = 1L; /** * 自增主键 */ private Long id; /** * 接收人邮箱(多个逗号分开) */ private String receiveEmail; /** * 主题 */ private String subject; /** * 发送内容 */ private String content; /** * 模板 */ private String template; /** * 发送时间 */ private Timestamp sendTime; } 邮件队列 public class MailQueue { //队列大小 static final int QUEUE_MAX_SIZE = 1000; static BlockingQueue<Email> blockingQueue = new

使用线程池+内存队列实现异步处理业务问题

人盡茶涼 提交于 2019-12-03 02:28:10
背景 当系统中的业务存在大量的相同任务(比如发送大量邮件),并且每个任务花费的时间也比较长,前端需要较快 的响应,针对这种需求,我们可以采用消息队列进行异步通知,同时也可以采用线程池+内存队列实现异步通知,处理业务问题。 代码实现 以下采用发送邮件作为demo 邮箱实体类 @Data public class Email implements Serializable { private static final long serialVersionUID = 1L; /** * 自增主键 */ private Long id; /** * 接收人邮箱(多个逗号分开) */ private String receiveEmail; /** * 主题 */ private String subject; /** * 发送内容 */ private String content; /** * 模板 */ private String template; /** * 发送时间 */ private Timestamp sendTime; } 邮件队列 public class MailQueue { //队列大小 static final int QUEUE_MAX_SIZE = 1000; static BlockingQueue<Email> blockingQueue = new

Gradle deprecated annotation processor warnings for lombok

不羁的心 提交于 2019-12-03 01:30:17
After upgrading to gradle 4.7, my previously warning-free build now emits this warning: The following annotation processors were detected on the compile classpath: 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor' and 'lombok.launch.AnnotationProcessorHider$ClaimingProcessor'. Detecting annotation processors on the compile classpath is deprecated and Gradle 5.0 will ignore them . Please add them to the annotation processor path instead. If you did not intend to use annotation processors, you can use the '-proc:none' compiler argument to ignore them. It seems that annotation

Lombok @builder on a class that extends another class

走远了吗. 提交于 2019-12-03 01:11:31
I have two classes Child extends Parent . I need to put @Builder annotation on the classes such that I do not need to create the builder my self. package jerry;// Internal compiler error: java.lang.NullPointerException import lombok.AllArgsConstructor; import lombok.Builder; @AllArgsConstructor(onConstructor=@__(@Builder)) public class Child extends Parent { //Multiple markers at this line // - Implicit super constructor Parent() is undefined. Must explicitly invoke another constructor // - overrides java.lang.Object.toString private String a; private int b; private boolean c; } @Builder

Adding Lombok plugin to IntelliJ project [duplicate]

99封情书 提交于 2019-12-02 21:54:11
This question already has answers here : Lombok annotations do not compile under Intellij idea [duplicate] (11 answers) I'm trying to add Lombok to my Spring Boot project in IntelliJ IDEA. So far, I've added the plugin under Settings - Plugins (version 0.13.16) added compile('org.projectlombok:lombok') to my Gradle dependencies enabled annotation processing It still doesn't recognize either the Lombok import or the annotations. What am I missing? Solved: I had to run an update on my Gradle file. You need to Enable Annotation Processing on IntelliJ IDEA > Settings > Build, Execution, Deployment