Lombok

Lombok IntelliJ IDEA Plugin: Use of var is disabled by default

不想你离开。 提交于 2019-12-11 08:48:51
问题 I'm using the Lombok Plugin for IntelliJ IDEA. When try to run Java code using the var keyword, I get the following error: Use of var is disabled by default. Please add 'lombok.var.flagUsage = ALLOW' to 'lombok.config' if you want to enable is. How do you do that in IntelliJ IDEA ? I created the lombok.config in the project root and pasted lombok.var.flagUsage = ALLOW but it didn't fix it. val is working but not var . I can't seem to find clear instructions on enabling var . My Lombok maven

NoClassDefFoundError: org.slf4j.LoggerFactory is a restricted class

大城市里の小女人 提交于 2019-12-11 08:25:15
问题 I am using maven for building a GAE/J web application. Until now I haven't had any problems but now whenever I try to run the development server I get a NoClassDefFoundError: org.slf4j.LoggerFactory is a restricted class . Here is an extract of the console log: ... INFO c.g.a.d.DevAppServerRunner - WARNING: failed JettyContainerService$ApiProxyHandler@4e4ad8a3: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory is a restricted class. Please see the Google App Engine developer's guide for

Lombok + Eclipse Kepler

送分小仙女□ 提交于 2019-12-11 07:58:50
问题 So, after updating eclipse from Helios to Kepler, I found my Lombok-dependent project to be full of errors, due to eclipse not seeing the added methods by @Getter and stuff, so i reinstalled Lombok, however eclipse either crashed or just didnt see the methods, depending on how i run it. If I ran it from eclipse.exe from windows explorer, it starts without lombok, and if i type it into the run dialog it just crashes like this: Java was started but returned exit code=1 C:\Windows\system32\javaw

Jackson Deserialization Fails because of non-default constructor created by lombok

岁酱吖の 提交于 2019-12-11 07:28:30
问题 Jackson can deserialize json for the following class in 2.6.5 but fails in 2.8.8. Model: public static class Parent { public long id; public List<Child> children; } @RequiredArgsConstructor public static class Child { public long childId; @NonNull @JsonIgnore public Parent parent; public Child() { } } JSON: { "id": 1, "children": [ { "childId": 2 } ] } The exception is: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "childId" (class Parent), not marked as

Jackson's BeanDeserializerModifier does not work with final fields

强颜欢笑 提交于 2019-12-11 07:21:31
问题 I wrote a Custom Serializer and Custom Deserializer to serialize properties marked with @Confidential annotation. @Data public class Person { private String name; @Confidential private String address; } The Custom Serializer serializes a POJO with following values: { "name": "John Doe", "address": "Kearney St"} as follows: {"name":"John Doe", "address": {"value":"IjIwMzEwIDU4dGggTG4gTkUi"}} The Custom Deserializer is also able to deserialize the JSON back to the Person POJO fine. However,

Intellij fails to detect the logger added by @Slf4j using Lombok

我的梦境 提交于 2019-12-11 05:59:22
问题 I am writing a simple app: @Slf4j public class MyApp { public static void main(String[] argv) { log.info("hello world!"); } } This code compiles just fine, and indeed, when run I see "hello world!" being logged out. Intellij however doesn't agree this works. I am constantly getting "Cannot resolve symbol log" even though this works and it compiles. Here's what I have done: I have installed the latest Lombok plugin I have enabled annotation processing All other Lombok annotations seem to work

Intellij 14 + lombok: @Slf4j Cannot find symbol log

半腔热情 提交于 2019-12-11 01:33:45
问题 Intellij doesn't recognize @SLF4J annotation. I have the following error: Error:(105, 9) java: cannot find symbol symbol: variable log location: class com.xxxxx.SdsConfig knowing that I have already Enable annotation processing (Settings -> Compiler -> Annotation Processors) I use java 8 compiler. 回答1: Use lombok plugin for Intellij: https://plugins.jetbrains.com/plugin/6317 This will highlight everything correctly and allow you to use auto completion for generated methods. Note that some

sonarqube 4.2 and lombok

旧巷老猫 提交于 2019-12-10 19:33:26
问题 After upgrading SonarQube from 4.0 to 4.2, I got a bunch of 'Unused private fields should be removed' errors from the classes with Lombok annotations. I have @SuppressWarnings("PMD.UnusedPrivateField") declared at the beginning of all those classes. It worked fine when I was using SonarQube 3.7 and 4.0. I use mvn sonar:sonar to generate the SonarQube report. And this shows how my class look like: @Data @SuppressWarnings("PMD.UnusedPrivateField") public class MyClass { private String field; }

Add Lombok plugin to IntelliJ

痴心易碎 提交于 2019-12-10 18:17:19
问题 Intellij doesn't recognize Spring annotations and I think its connected to Lombok. I added the plugin in IntelliJ settings and enabled annotation processing I am using maven and I have this dependency dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> Still Intellij can't recognize Slf4j and Spring annotations 回答1: Follow the steps 1. Build spring application as mentioned in: https://spring.io/guides/gs/spring-boot/ Install

Making all parameters final with an annotation in Java

独自空忆成欢 提交于 2019-12-10 18:00:48
问题 I've recently been working with Lombok--and I'm wondering it would be possible to provide a class level or method level annotation that adds final to all parameters. For example: @finalizer void foo(Bar bar); Becomes void foo(final Bar bar); 回答1: It is possible. Lombok could do it, there's already the FieldDefaults annotation allowing to make all fields final by default. Doing this for parameters would be even easier. While final on fields is something the JVM deals with (by not allowing