Search code examples
code-injectionnetbeans-8lombok

methods injected by lombok not recognized inside the same class


During a simple use of lombok, IDEs such as Netbeans, Intellij allows the use of methods injected by the library lombok for example @Getter & @Setter.

import lombok.Getter;

public class Test {

    @Getter
    private Double var;   

    public Double calculTva(double tva) {
        return this.getVar() * tva;
    }
}

The code return this.getVar() is not recognized by the Test class. But if we use an another class, for example Test2, in this case we can use the getter method.

public class Test2 {     

    public Double calculTva(double tva) {
        Test t =new Test();
        return t.getVar() * tva;
    }
}

Environnement :

  1. Netbeans 8.0.2
  2. lombok 1.16.13
  3. Jdk 1.7
  4. Project type Java application

Solution

  • In your NetBeans IDE, follow this instructions :

    1. Open your poject
    2. Project properties
    3. Build / Compiling / Enable annotation processing
    4. Change to true (chechk it) the value of Enable Annotation Processing in Editor.
    5. Save & test