简体   繁体   中英

Intellij Idea Lombok. @Data etc. are not working

I am trying to use Lombok in my IntelliJ Idea 2016.2.5 Maven project. I have already installed Lombok Plugin for IntelliJ (v. 0.13.16) and added dependency do pom.xml .

However, it is still not working. I have created a sample class to check if Getters and Setters etc. are made , and they are not :( I have tried to add a Maven Lombok Plugin but it also did not work.

I am posting a screenshot from Intellij showing my problem. Everything else is working properly so i don't have any error log etc.

在此处输入图片说明

Does anybody know what is the problem?

My plugin configuration :

<plugin>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok-maven-plugin</artifactId>
    <version>1.16.10.0</version>
    <executions>
      <execution>
        <id>delombok</id>
        <phase>generate-sources</phase>
        <goals>
          <goal>delombok</goal>
        </goals>
        <configuration>
          <addOutputDirectory>false</addOutputDirectory>
          <sourceDirectory>src/main/java</sourceDirectory>
        </configuration>
      </execution>
    </executions>
  </plugin>

After trying to run delombok i go an error

[ERROR] Failed to execute goal org.projectlombok:lombok-maven-plugin:1.16.10.0:testDelombok (default-cli) on project Projekt9: The parameters 'encoding' for goal org.projectlombok:lombok-maven-plugin:1.16.10.0:testDelombok are missing or invalid -> [Help 1]

@Edit

Problem is solved . Just needed to restart IDEA after all stuff :)

I think you're missing the important annotations: @Getter @Setter

They should be above your class declaration. The plugin makes them visible in your IDE, and (not 100% sure) compiletime the real getters and setters are created.

My example of lombok-maven-plugin configuration looks like this:

<plugin>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok-maven-plugin</artifactId>
    <version>1.16.8.0</version>
    <executions>
        <execution>
            <id>delombok</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>delombok</goal>
            </goals>
            <configuration>
                <addOutputDirectory>false</addOutputDirectory>
                <sourceDirectory>src/main/java</sourceDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

If you are going to use lombok with IDEA don't forget to exclude sources generated by maven ( File -> Project Structure -> Module -> Your Module -> target/generated-sources/delombok mark as Excluded ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM