Problem
Spring Boot application execution from within IntelliJ fails with the following error:
variable currentHostname not initialized in the default constructor
private final String currentHostname;
The simple class looks like this:
package com.painstakingminds.mls.saml_login.security.utils;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public class HostingInfo {
private final String currentHostname;
private final String currentTenantId;
}
Lombok plugin and annotation processing are enabled, and also Lombok is referenced in build.gradle:
dependencies {
....
implementation 'org.projectlombok:lombok'
}
Resolution
The fix is in IntelliJ IDEA 2024.3.3 (Annotation processor version not imported from maven dependecyManagement). Users still report the error in 2025.1, so if it appears in your version, use the workaround below.
Workaround:
For Gradle:
Add the following dependencies to build.gradle file instead of the one already added: implementation 'org.projectlombok:lombok'.
def lombok_version = '<version>'
dependencies {
...
compileOnly 'org.projectlombok:lombok:$lombok_version'
annotationProcessor 'org.projectlombok:lombok:$lombok_version'
testCompileOnly 'org.projectlombok:lombok:$lombok_version'
testAnnotationProcessor 'org.projectlombok:lombok:$lombok_version'
...
}
Replace the <version> placeholder in the first line with the lombok version number.
For Maven
Make sure an actual <annotationProcessorPath> is added to the lombok plugin configuration in your pom.xml. Make sure <version>${lombok.version}</version> is specified for it:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Related issues
Annotation processor version not imported from maven dependecyManagement
Comments
0 comments
Please sign in to leave a comment.