2

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.

choiasher
  • 23
  • 4
  • Building with gradle and then enabling annotation processing in your IDE won't help. You will need to configure lombok in gradle to have the annotation processor work. Have you followed [the official guide for lombok with gradle](https://projectlombok.org/setup/gradle)? – M. Deinum Dec 11 '19 at 07:12
  • @M.Deinum It's working tnk very much! – choiasher Dec 12 '19 at 01:05

5 Answers5

1

You need to install lombok plugin to Intellij. You can use following url to download.

Lombok Plugin

Channa
  • 3,267
  • 7
  • 41
  • 67
  • 1
    try adding `@AllArgsConstructor` annotation as well just under `@Getter` annotation – Channa Dec 11 '19 at 05:22
  • sorry then I don't know how to help. You can have look at this, he seems had a solution. https://github.com/tbroyer/gradle-apt-plugin/issues/10 – Channa Dec 11 '19 at 05:37
-1

Install the needed plugin for Lombok...

Lombok is not supported out of the box.

jwenting
  • 5,505
  • 2
  • 25
  • 30
-1

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.

Ambuj
  • 63
  • 1
  • 7
-1

This problem is resolved, please have a look into the below StackOverflow URL

Download IntelliJ Plugin Lombok IntelliJ plugin

Tapan
  • 285
  • 2
  • 8
-1

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.

Sushil Mittal
  • 494
  • 4
  • 10