How to use Lombok plugin in IntelliJ 2021.2.2? - java

I am new to Java from c++ and I have been trying to familiarise myself with the language.
I am trying to use the lombok plugin from IntelliJ IDEA but it does not seem to work for me at all:
This is a screenshot of my IDEA failing to recognise the "#value" annotation
The lombok is already installed on my IDEA and I have tried restore the default settings of my ide a bunch of times but I still get the same error:
This is a screenshot of the lombok plugin install on my ide
I am using the IntelliJ IDEA 2021.2.2 (Ultimate Edition).
Does anyone know what's the problem?

I have never used the Lombok plugin through the IDE. The way I do know how to use it is as follows:
Make sure that when you create a new project through your IDE that you're selecting either a maven project or a gradle project, these are project types that help you manage your dependencies in an intuitive way(I'll use maven for this example).
Go to either https://projectlombok.org/setup/maven or https://projectlombok.org/setup/gradle depending on the project type you've chosen you'll have to copy and paste the text block from these respective url's into either your pom.xml file(for maven) or your build.gradle file(for gradle)
For Maven:
For Gradle:
Paste the text block into your pom.xml or build.gradle like so(don't forget to click the M that shows up that's hovered over by the cursor, this updates your project with the new dependency so you can use actually use lombok):
Now you should be able to use Lombok and make use of all it's boilerplate goodness :)

I've been run into this issue, it was caused by Lombok version conflict, using the latest version works for me, you can use maven helper idea plugin to see if it's the same case for you.

I came across the same issue and found an intellij IDEA plugin called Delombok. It seems this plugin is part of the projectlombok. Anyone facing the same issue can try it out! By the way I am using IntelliJ IDEA 2022.1.4 (Ultimate Edition).

Related

IntelliJ Kotlin - How do I fix "Ensure that you have a dependency on the Kotlin standard library" in a project?

I've been trying to set up a new Kotlin project in IntelliJ IDEA, using the default IntelliJ Build System (not Gradle) and JDK 15. Whenever it creates the default main.kt file, and I try to build and run the main function, which looks like this:
fun main(args: Array<String>) {
println("Hello World!")
}
the build fails after a short time with the following errors:
Kotlin: Cannot access built-in declaration 'kotlin.Array'. Ensure that you have a dependency on the Kotlin standard library
Kotlin: Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library
and
Kotlin: Unresolved reference: println
I've tried changing the project SDK to the kotlin SDK, to Java 14 and to Java 1.8. I'm not sure exactly how to add the dependency it asks for. Any help is appreciated.
This is what the dependencies window shows within the project:
Right now the project is using JDK 15, and Kotlin 1.4.10. I've tried updating the plugin, uninstalling and reinstalling, deactivating and reactivating, all to no avail.
The project files can be found here on Google Drive
Try enabling KotlinJavaRuntime
Open Project Structure window (File > Project Structure)
Go into Modules
Go to Dependencies tab
Tick the Enable KotlinJavaRuntime checkbox
Removing the .idea/library file inside the project directory and then selecting "use library from plugin" when prompted to configure Kotlin files by the IDE solved the problem.
Please provide more information and check what Kotlin version do you have installed:
Tools > Kotlin > Configure Kotlin Plugin Updates: install the latest version of Kotlin
File > Project Structure > Project: what is your Project SDK there? Choose 15 (something line java version "15.0.1"). If you don't have 15 there, click "+" and add the newest version (unless you need an older version).
Probably you need to add KotlinJavaRuntime library in you project. Please see paragraph "Create Kotlin files in Java projects" in https://www.jetbrains.com/help/idea/mixing-java-and-kotlin-in-one-project.html
After configuration you should see needed jars in lib folder in your project. Rebuild you project. Make also File->Invalidate Cache/Restart.
I tried all of the above but eventually found out, that in one project, my SDKs were completely broken after the newest Intellij Update. If you go to Project Structure -> Platform Settings -> SDKs, I had an entry for Kotlin with a non existing path for an Intellij Version of last year. This was definitely not there before and it seems to have messed up the kotlin installation. After i deleted that entry and as described above the libraries as well, it worked again.
For me this helped:
Close the project
Delete idea. folder
Open project
I have a Ubuntu 16.04 with IntelliJ 2020.3 newly installed. I run to the same issue here.
To solve this issue, I made a new kotlin file in my project. Then when the system was trying to add this new Kotlin file, you can find a notification related to "Configure project" on the right bottom corner of screen, click the notification. I get the following dialog.
Then check the Use library from plugin, this solve the issue.
Use library from plugin
In this case, it was a misconfigured IntelliJ instance.
Project Structure -> SDKs -> kotlinSDK -> + -> ok
rebuild will be work fine
In my case the Kotlin Standard Library JDK extension was missing. https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-jdk8
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.7.21</version>
</dependency>

"Package javax.xml.ws does not exist"

I am rusty on Java and completely new to IntelliJ IDEA, an IDE which has been causing a lot of problems for me so far.
I am trying to run a program with the line "import javax.xml.ws.Response;". However, I get the error message "package javax.xml.ws does not exist."
I've tried to select the "Add Java EE 6 JARs to module dependencies" automated solution by IntelliJ IDEA, but it doesn't seem to do anything.
(I believe I am running Java 11, if it makes any difference at all. According to the readme by the author of the code, I should be running Java 8, but so far I haven't been able to because I get an unrelated error when trying to change Java versions with IntelliJ.)
What do I do? Thanks in advance.
Your issue is not related to Java version. It will work for both version 8 and 11.
You will need to either download the jaxws-api jar or add it as a Maven dependency accordingly.
You may download the Jar from the below maven repository URL, and then add it to your build path, or update your pom.xml with this dependency:
https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api/2.3.1
This is intermittent issue and can eat up hours. Try to do below steps
Remove all dependencies from classpath.
Close the project and open it again.
Add all required dependencies.
Clean your project.
Go to Project Structure and change Project SDK to Java 1.8 solved my problem

no gradle tool in Tool windows in idea

How to make show up gradle Projects in idea.I search from View->Tool Window-> but there is only maven project. I already loaded gradle project, but I can't manage it due to not existing gradle projects.How I could make show up it or I should download it from somewhere
IntelliJ have certainly had trouble solving this particular problem, but as of 2018.3.6 the solution has certainly gotten better:
find the gradle.build file
right-click on it and select Import Gradle Project.
no idea () why they've decided to do it this way, but it works, the Gradle tool window becomes available, and it has become a gradle project.
C:\Users\user\AppData\Roaming\JetBrains\IdeaIC2021.2
There is a disabled_plugins.txt, open it and delete the "org.gradle..." things and save it. Restart IntelliJ. It helped me, there are Gradle options in New Projects.

Unable to resolve errors in maven project eclipse photon

I have imported an existing manven project into my eclipse new workspace which I downloaded from github. On maven install I get a BUILD SUCCESS but the red cross on the project never goes. This issue has been raised previously : link1, link2
Most of the solutions tell about update project and any number times I do update project, It doesn't solve the problem.
The other solution is about having lombok plug-in because I noticed that many of the getter and setter methods are causing problems(absent). The lombok plug-in is to auto-generate them....I have it in my pom.xml but still the problem persists. In fact the problems tab shows a 100 errors like the samples below:
__ cannot be resolved to a type
The blank final field API_KEY may not have been initialized
The constructor APNSService(ApnsService) is undefined
How to solve this issue?
Any help is appreciated.
Note: I am running the maven project on jdk1.8.
You also must have the lombok plugin installed in Eclipse. (Note that this is something different from lombok being present in the project dependencies; you need both.) Furthermore, the version installed in Eclipse should be the same version that you have in your pom.xml. Otherwise strange compilation issues may occur, like code compiling in Eclipse but not in maven, or vice versa.
Installation instructions for Eclipse can be found here.
UPDATE:
Check the "About Eclipse" dialog after the installation and an Eclipse restart. It must contain some text like "Lombok v1.18.3 "Edgy Guinea Pig" is installed.". If that is not the case, the lombok plugin is not installed correctly.
If the installation was not successful, you should try installing lombok to a clean Eclipse installation (even before adding any projects). You could also try Eclipse Oxygen instead of Photon (there are sporadic reports of problems with Photon; however, there seems to be no general issue in combination with Photon).
Explanation: Eclipse uses its own compiler (different from javac, which maven uses). Therefore, lombok also has to hook into the Eclipse compilation process, and therefore, Eclipse needs that lombok plugin.

Cucumber is not recognizing defined steps "Undefined Steps"

I can't execute a simple test with cucumber for a project. I am on Intellij 13 Community, with cucumber plugin.
I wrote my feature file in my features directory, I have also implemented my steps creating them with the help of the plugin. My steps in the feature files are recognized by intellij, which can navigate and go to the step implementation.
When I try to run my scenario, if fails stating "Undefined step". Any help will be greatly appreciated.
Here is how i organized my project :
It sounds as if you are trying to run the feature from Idea. It also sounds as if you have some issue with the wiring of your project.
My approach would be to start with something that works and then modify it to suit your needs. A project that works is the Java skeleton provided by the Cucymber team. Download or clone it from GitHub: https://github.com/cucumber/cucumber-java-skeleton
You should be able to build this project using Maven, Ant, or Gradle. It will also be possible to open it using IntelliJ IDEA and modify it to suit your needs.

Categories