Lombok provides a nice trick to generate constructors with additional annotations added to them. This helps a lot with writing code that uses dependency injection, e.g. with Spring Framework.
A simple testcase looks as following:
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SomeService {
private final SomeRepository someRepository;
private final AnotherRepository anotherRepository;
public void someLogic() {
}
}
The problem is that that Lombok Intellij plugin doesn't seem to understand Lombok's specific @__ syntax.
It works for me with Spring Framework, Latest intelliJ version (2016.1) and latest Lombok Plugin version. In fact, I'm using that functionality of Lombok on a daily basis.
Questions:
I'm using IntelliJ 2016.1.1, Lombok plugin 0.11.16, and lombok 1.16.8.
The error message I get is:
Error:(18, 43) java: cannot find symbol
symbol: class __
I uploaded a test project to https://github.com/mkochenough/lombok-test
it would seem that you do not have annotation processing enabled for your IntelliJ, according to .idea/compiler.xml
For lombok to work, please enable it.
You are right. I setup a new IntelliJ and totally forgot about this. Sorry for the annoyance.
No problem, glad this works for you now!
it does not work ,even I enabled it,why?
I have the same issue with him ,even i enable the annotation prossession
It doesn't work for me either. Using the following annotation:
@AllArgsConstructor(onConstructor = @__(@Inject)
Others annotations seem to be working fine.
+1
@RequiredArgsConstructor(onConstructor_={@Autowired}) è¿™æ ·å†™æ³•æ ‡çº¢å‘¢
This is still happening for Intellij 2020.3 and latest lombok plugin version.
@AllArgsConstructor(onConstructor = @__(@Inject)
cannot find symbol
symbol: class __
Most helpful comment
This is still happening for Intellij 2020.3 and latest lombok plugin version.
@AllArgsConstructor(onConstructor = @__(@Inject)
cannot find symbol
symbol: class __