javaintellij-idealombokintellij-lombok-plugin

How to use Lombok plugin in IntelliJ 2021.2.2?


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?


Solution

  • I have never used the Lombok plugin through the IDE. The way I do know how to use it is as follows:

    1. 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). Maven or Gradle project

    2. 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: enter image description here

    For Gradle: enter image description here

    1. 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): enter image description here

    2. Now you should be able to use Lombok and make use of all it's boilerplate goodness :) enter image description here