Reputation: 53
I am not sure what am I doing wrong. Can somebody please help me out
The builder() method does not seem to be recognised. I am using IntelliJ. Is there something that I am missing?
Below are my intelliJ settings:
Upvotes: 5
Views: 14653
Reputation: 1
Had the same issue. In my case, setting "Delegate IDE build/run actions to Maven" solved it.
Seetings - Build, Execution, Deployment - Build Tools - Maven - Runner
Upvotes: 0
Reputation: 57
If you're having multiple modules as microservices within a parent module then place below code in pom.xml of parent module:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
After that in intellIJ, go to settings -> Build, execution, deployment -> Compiler ->Annotation Processors select obtain processors from project classpath for each module.
Upvotes: 1
Reputation: 1178
In my case, I had used @Data
and @NoArgsConstructor
.
To get the @Builder
to work, I had to add @AllArgsConstructor
.
@NoArgsConstructor
seems to invalidate the [all-args] constructor @Data
adds. So either have just @Data
or both @NoArgsConstructor
& @AllArgsConstructor
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ThatGreatClassName implements Serializable {
// code
}
OR
@Data
@Builder
public class ThatGreatClassName implements Serializable {
// code
}
Upvotes: 1
Reputation: 44496
Aside from the dependency in the provided
scope you have to enable the annotation processing (if you are using IntelliJ Idea) and install the Lombok Plugin.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
Annotation processing: Navigate to File
-> Settings
-> Build, Execution, Deployment
-> Compiler
-> Annotation Processors
and check Enable annotation processing
.
Lombok Plugin: Navigate to File
-> Settings
-> Plugins
and make sure the Lombok plugin is installed.
Restart IntelliJ Idea - The most likely missed part :)
Upvotes: 3
Reputation: 1891
Assuming you use IntelliJ: You have to install Lombok Plugin in order to make it work:
File > Settings > Plugins
Lombok Plugin
Upvotes: 2