Document how to use Lombok with Micronaut
See original GitHub issueI tried to use Micronaut with Lombok and there seems to be some kind of conflict between the annotation processing and compile-time tasks that Micronaut executes to process DI and the class metadata, and the annotation processing that Lombok does.
Task List
- Steps to reproduce provided
- Stacktrace (if present) provided
- Example that reproduces the problem uploaded to Github
- Full description of the issue provided (see below)
Steps to Reproduce
- Create a simple micronaut project with gradle-lombok plugin
- Create a Controller (or any other DI enabled class)
- Create a simple Dto with
@Dataor other annotation from Lombok - Call one of the generated methods of the Dto from inside the Controller
An important point to highlight is that if I don’t use annotations on the Controller, the build is successful (as it doesn’t generate all the metadata classes).
Expected Behaviour
Compile successful
Actual Behaviour
Compile error: symbol not found
Environment Information
- Operating System: Mac/bash
- Micronaut Version: 1.0.0-SNAPSHOT
- JDK Version: 1.8.0_121
Example Application
build.gradle
plugins {
id 'io.franzbecker.gradle-lombok' version '1.14'
id 'java'
}
GreetingDto.java
@Data
public class GreetingDto {
private String greeting;
}
GreetingController.java
@Controller("/hello-world")
public class GreetingController {
@Get
public GreetingDto login(){
GreetingDto dto = new GreetingDto();
dto.setGreeting("Hello world!");
return dto;
}
}
Console output
> Task :compileJava FAILED
Note: Creating bean classes for 1 type elements
/Users/sebastian/development/hello-world/src/main/java/controller/GreetingController.java:17: error: cannot find symbol
dto.setGreeting("Hello world!");
^
symbol: method setGreeting(String)
location: variable dto of type GreetingDto
1 error
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Management & Monitoring - Micronaut Documentation
Micronaut is a modern, JVM-based, full stack Java framework designed for building modular, easily testable JVM applications with support for Java, Kotlin, and ......
Read more >java - Why lombok, micronaut and querydsl does not work with ...
I have this error with @Slfj java: cannot find symbol symbol: variable log. Why lombok, micronaut and querydsl does not work with micronaut...
Read more >13.1.3 Using Project Lombok - 《Micronaut v2.3.1 ... - 书栈网
13.1.3 Using Project Lombok Micronaut is a modern, JVM-based, full stack Java framework designed for building modular, easily testable JVM ...
Read more >Micronaut Data - GitHub Pages
If you intend to use Lombok with Micronaut Data then you must place the Lombok annotation processor before the Micronaut processors in your...
Read more >Micronaut | IntelliJ IDEA Documentation - JetBrains
Create a new Micronaut project · Launch IntelliJ IDEA. If the Welcome screen opens, click New Project. Otherwise, from the main menu, select ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In maven, I had to add lombok processor to pom file explicitly and before micronaut processor
Seems if you define:
Before
Your example compiles. This does however seem fragile to me.