IDE:IntelliJ IDEA 2020.3.2 (Ultimate Edition)
Play:1.4.4
Lombok:1.18.18
Exception:play.exceptions.CompilationException: The method getId() is undefined for the type Order
at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:264)
at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:678)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:522)
at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:300)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:420)
at play.classloading.ApplicationClassloader.getAssignableClasses(ApplicationClassloader.java:466)
at play.templates.GroovyTemplateCompiler.endTag(GroovyTemplateCompiler.java:362)
at play.templates.TemplateCompiler.generate(TemplateCompiler.java:93)
at play.templates.TemplateCompiler.compile(TemplateCompiler.java:15)
at play.templates.GroovyTemplateCompiler.compile(GroovyTemplateCompiler.java:39)
at play.templates.TemplateCompiler.compile(TemplateCompiler.java:28)
at play.templates.TemplateLoader.load(TemplateLoader.java:85)
at play.templates.TemplateLoader.load(TemplateLoader.java:180)
at play.server.PlayHandler.serve500(PlayHandler.java:836)
at Invocation.HTTP Request(Play!)
I already checked the settings here, but that didn't fix the problem:
I managed to make it work on a gradle project (Intellij 2020.3.2)
by using exactly this in build.gradle :
annotationProcessor 'org.projectlombok:lombok'
I think important point is to declare it as "annotationProcessor" type and not "compile" or so.
if someone gets the same issues, I found the answer
just keep the IntelliJ setting all the right
then I trying to change the Lombok version
Playframework - 1.4.4
Lombok - 1.18.2
IntelliJ - 2020.3
IntelliJ Plugins - Lombok 0.32-EAP
that's work ...
Related
It seems like many people are having this problem, but none of the problems i have researched so far are that basic like my problem.
I only got this object:
and a basic call in my main method:
Bamm... already not working. The compilataion fails with this error
I am using IntelliJ and have installed the Lombok plugin.
If it helps... here is my build.gradle:
Any ideas ?
Lombok uses the annotation processor to do its magic so you have to add lombok annotationProcessor dependency in your build.gradle file. Add this line inside your dependencies block:
annotationProcessor 'org.projectlombok:lombok:1.18.6'
It's seem lombok annotation is not working.
import lombok.Getter;
import lombok.RequiredArgsConstructor;
#Getter
#RequiredArgsConstructor
public class HelloResponseDto {
private final String name;
private final int amount;
}
and here is output
> Task :cleanTest UP-TO-DATE
> Task :compileJava FAILED
C:\Users\tahun\IdeaProjects\spring-tutorial\src\main\java\org\example\springboot\web\dto\HelloResponseDto.java:10: error: variable name not initialized in the default constructor
private final String name;
^
C:\Users\tahun\IdeaProjects\spring-tutorial\src\main\java\org\example\springboot\web\dto\HelloResponseDto.java:11: error: variable amount not initialized in the default constructor
private final int amount;
I'm working with Intellij so I also checked
Settings > Compiler > Annotation Processors > Enable annotaion processing
and i also add compile('org.projectlombok:lombok') in my build.gradle
Is there any solutions?
==more==
I also installed lombok plugin.
You need to install lombok plugin to Intellij. You can use following url to download.
Lombok Plugin
Install the needed plugin for Lombok...
Lombok is not supported out of the box.
You can add the lombok plugin - https://plugins.jetbrains.com/plugin/6317-lombok/
Go to Setting --> plugins and search for lombok and add the plugin.
Restart and check. IntelliJ should not report any error of lombok.
This problem is resolved, please have a look into the below StackOverflow URL
Adding Lombok plugin to IntelliJ project [duplicate]
Lombok annotations do not compile under Intellij idea [duplicate]
Can't compile project when I'm using Lombok under IntelliJ IDEA
Download IntelliJ Plugin Lombok IntelliJ plugin
its very easy to configure lombok in IntelliJ using below steps:
1.Go to Setting --> plugins and search for lombok and add the plugin.
2. restart the intelliJ
3. check if working or not , if still not working then restart your system due to some time not able to configure new plugin properly.
I am building a web application and I am using Dropwizard 1.3.0, which has a dependency on jetty-io 9.4.8. This dependency has conflicts with another package (dropwizard-websocket-jee7-bundle 2.0.0), because it seem to fetch the wrong version number.
I looked into tha package, and found the method that has been renamed in 9.4.x - AbstractWebSocketConnection.java from 9.3.x - AbstractWebSocketConnection.java. The issue is that even though in Gradle the dependency tree shows I fetched 9.4.8 (the new one which I need), I still get the older, 9.3.x java file which causes the conflicts. I tried to Invalidate Caches / Restart and rebuild the whole project, but I seem to get the outdated file all the time.
What are the possible solutions for this?
If your bad class are imported by a transitive dependency, try to exclude explicit the transitive dependency.
For example if your required library is 'my.group:requiredLibrary:2.0.0' and there are another version in 'my.group:someDependency:0.1.5' you can do like this:
dependencies{
compile 'my.group:requiredLibrary:2.0.0'
compile ('my.group:someDependency:0.1.5'){
exclude group: 'my.group' module:'requiredLibrary'
}
}
Try forcing a particular version in your build.gradle
Example here: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html
I am trying to introduce Lombok into my project. Everything builds fine when I compile it locally but on Jenkins it reports this problem and then it fail on all the getters and setter which I replaced with #Data anotation. Jenkins uses Java 1.8. Any idea what might be wrong?
[INFO] Compiling 154 source files to /var/lib/jenkins/jobs/MERGE REQUEST build error_prone/workspace/com.betradar.betpal.server.app.api/target/classes
/var/lib/jenkins/jobs/MERGE REQUEST build error_prone/workspace/com.betradar.betpal.server.app.api/src/main/java/com/betradar/betpal/server/app/message/ObjectFactory.java:22: warning: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException: com.google.errorprone.MaskedClassLoader$1$1 extends com.sun.tools.javac.file.JavacFileManager
public class ObjectFactory {
^
at lombok.javac.apt.LombokFileObjects.getCompiler(LombokFileObjects.java:148)
at lombok.javac.apt.InterceptingJavaFileManager.<init>(InterceptingJavaFileManager.java:40)
...
Errorprone uses the java9 compiler under the hood. There are two possible solutions:
Upgrade the Lombok dependency to 1.16.20
Downgrade the errorprone dependency
I just started doing dependency injection using Dagger 2. When I spun up my modules, components and tried to build my application, gradle threw the error
Error:(4, 24) error: cannot find symbol class Generated
I dug into it and found that the error is in one of the classes Dagger generates to do DI. The particular class that's missing was javax.annotation.Generated and the line throwing the error is the line that anntotates a Dagger generated class as #Generated("dagger.internal.codegen.ComponentProcessor")
This question helped in finding the solution which is to add the javax package as a dependency by adding the line compile 'org.glassfish:javax.annotation:10.0-b28' to my gradle build file. This led to a successful build.
My question is, why is that not added as a transitive dependency for Dagger or why hasn't anyone else faced this particular issue (I assume so, since I couldn't find any question here regarding this?
TL;DR use Dagger >= 2.1
Alex is right, but it's better to add JSR250 dependency instead of GlassFish
provided 'javax.annotation:jsr250-api:1.0'
or for the latest gradle plugin:
compileOnly 'javax.annotation:jsr250-api:1.0'
Read this for more info: https://github.com/google/dagger/issues/95
Basically, the solution is to do what you've already done which is include the glassfish javax annotation library.
This happens if your JAVA_HOME points to JAVA version 9 or 10. Switching JAVA_HOME to Java 8 fixes the problem and you will not need that extra dependency.
I downgraded my JVM to Java 8 and running gradle build was successful in my Android application using Dagger 2.
The right answer today is to use a version of dagger which is greater than 2.1 (because of the fix mentioned by #tomrozb is integrated in 2.1)