Micronaut with Lombok using Maven

Voiced by Amazon Polly

Recently I have encountered a problem with getting Lombok to work with Micronaut. Code would not compile because Lombok’s methods weren’t generated. Log was populated with compilation errors saying that auto-generated methods cannot be found, like so:

[ERROR] /src/main/java/com/vaytee/product/AddProductFunction.java:[22,47] cannot find symbol
[ERROR] symbol:   method getName()

The solution to setup Micronaut with Lombok was to add annotation processor path to Maven configuration:

<annotationProcessorPaths>
    <path>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
    </path>
    <path>
        <groupId>io.micronaut</groupId>
        <artifactId>micronaut-inject-java</artifactId>
        <version>${micronaut.version}</version>
    </path>
    ...
</annotationProcessorPaths>
After applying that simple change project started to build with success.

Leave a Reply

Your email address will not be published. Required fields are marked *