Lombok

Lombok not working with Intellij

跟風遠走 提交于 2019-12-10 17:12:59
问题 I am not able to use any of the lombok annotations in Intellij, it works fine in Eclipse. So far, I have done the following things: Added lombok dependency in eclipse Installed the lombok plugin Enabled annotation processing However, I cannot use any of the lombok annotations, eg: using @Builder gives error because import lombok.Builder does not exists. I am using IDEA 2018.2.1 CE Any ideas, what am I doing wrong? MVN dependency: Can see the dependency resolved: Can see the lombok plugin:

java.lang.String cannot be converted to org.slf4j.Marker

谁说胖子不能爱 提交于 2019-12-10 16:35:36
问题 I'm using import lombok.extern.slf4j.Slf4j; for my class, and here's my log statement: log.info("{} : {} - {}", String1, String2, String3); But it fails to compile and complaining the above line: java.lang.String cannot be converted to org.slf4j.Marker Any ideas please? 回答1: I guess that you are willing to use info(String format, Object... arguments) and are wondering why the method that is really called is info(Marker marker, String format, Object arg1, Object arg2) . This is related to Most

Jackson deserialize array elements into specific fields

自古美人都是妖i 提交于 2019-12-10 15:25:47
问题 Is there a Jackson annotation that will allow an array to be deserialized into specific fields of my POJO? I can easily do this with a custom deserializer, but I was hoping to get this done in-line with the class. For example, I have the following JSON coming back from Elasticsearch. { "_index": "twitter", "_type": "tweet", "_id": "AVodOsgk0etILSbJamY-", "_score": null, "_source": { "tweetText": "I'm at Residencial Nova Alegria https:\/\/t.co\/4TyK8PAWzB", "placeCountry": "Brasil",

SpringBoot 自动代码生成三层

此生再无相见时 提交于 2019-12-10 06:58:11
前言 虽然mybatis已经有了代码生成,但是对于SpringBoot 项目来说生成的还是需要改动,而且也没得逻辑层,和控制层。但是这些东西是逃避不了,所以我就针对单表,做了一个代码生成器。 mybatis-dsc-generator 根据完善的数据库表结构,一键生成dao.java,mapper.xml,service.java,serviceImpl.java,controller.java,完成单表的增删改查、组合条件集合查询,组合条件分页查询。 源码地址 GitHub: https://github.com/flying-cattle/mybatis-dsc-generator 码云: https://gitee.com/flying-cattle/mybatis-dsc-generator MAVEN地址 <dependency> <groupId>com.github.flying-cattle</groupId> <artifactId>mybatis-dsc-generator</artifactId> <version>1.0.0.RELEASE</version> </dependency> 数据表结构样式 CREATE TABLE `order` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',

Is it possible to use Lombok with Kotlin?

时间秒杀一切 提交于 2019-12-10 00:42:29
问题 I have a Kotlin Gradle project. I added Lombok as a dependency and also registred it with kapt compileOnly("org.projectlombok:lombok:$lombokVersion") kapt("org.projectlombok:lombok:$lombokVersion") I would like to use just @Slf4j anotation for automatic log generation. It works for Java classes but not for the Kotlin ones. Is using Kotling and Lombok together even possible as of now ? EDIT: Adding more details If I annotate a Kotlin classs with @Slf4j and use log inside it I get Unresolved

Using Dagger2 with Lombok

喜夏-厌秋 提交于 2019-12-09 16:43:42
问题 Has anyone used Lombok 1.16 with Dagger2? My current code looks like: @AllArgsConstructor(onConstructor = @__(@Inject)) public class JuiceMaker { private final Apple apple; The error is: JuiceMaker cannot be provided without an @Inject constructor or from an @Provides-annotated method. Without the Lombok annotation this actually works, so: public class JuiceMaker { private final Apple apple; @Inject public JuiceMaker(Apple apple){ this.apple = apple } } works 回答1: This is a copy paste version

Immutable Lombok annotated class with Jackson

爷,独闯天下 提交于 2019-12-09 14:31:00
问题 What is the preferred way to create class that is Immutable Can be serialized/deserialized with Jackson Human-readable and with low level of boilerplate Preferably, I would have liked something like this to work: @Data(onConstructor = @__(@JsonCreator)) and then have all fields to be private final . However, this does not even compile (and I'm not sure why). Using @AllArgsConstructor(onConstructor = @__(@JsonCreator)) will compile but only yields InvalidDefinitionException: No serializer

当使用lombok @Data后使相等更简单的坑

冷暖自知 提交于 2019-12-09 12:01:22
最近在用到removeAll时遇到的疑问。 分析问题 实体类 @Data public class EntityVo extends Entity { ..... } 通过 Collection 集合去实现删除包含的元素 collection.removeAll(arr); 代码一执行,全部都被删了 原因解析: 先看API boolean removeAll(Collection<?> c) 从列表中移除指定 collection 中包含的其所有元素(可选操作)。 没错,就是移除子集合包含的元素 再看API说明,移除所包含的其所有元素,注意这个字眼:包含! 因为在执行removeAll方法时,会先对集合元素进行比较,如果元素相等才执行移除操作,说到这,相信很多人都已经明白是怎么回事了,因为相等(equals),所以执行移除。 查看源码进一步证实上述猜测,remove和removeAll的方法实现在: java.util.AbstractCollection<E> 具体代码为: public boolean removeAll(Collection<?> c) { boolean modified = false; Iterator<?> it = iterator(); while (it.hasNext()) { if (c.contains(it.next())) { it

Jackson deserialize default values missing

梦想与她 提交于 2019-12-09 07:55:18
问题 I try to deserialize a JSON object that I receive in my API using the following code: ObjectMapper mapper = new ObjectMapper(); ExampleDto ed = mapper.readValue(req.body(), ExampleDto.class); My class uses Lombok to generate constructors, getters and setters, and looks like this: @Data @AllArgsConstructor @NoArgsConstructor public class ExampleDto { private String name = ""; private List<String> values = new LinkedList<>(); } Both properties should be optional, and use the default value

Lombok does not work for Eclipse Neon

若如初见. 提交于 2019-12-09 05:05:54
问题 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