Lombok-intellij-plugin: onConstructor handling

Created on 10 Apr 2016  Â·  11Comments  Â·  Source: mplushnikov/lombok-intellij-plugin

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.

invalid

Most helpful comment

This is still happening for Intellij 2020.3 and latest lombok plugin version.

@AllArgsConstructor(onConstructor = @__(@Inject)
cannot find symbol
symbol: class __

All 11 comments

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:

  • What versions of IntelliJ, Lombok plugin and Lombok dependency are you using?
  • Could you provide a basic project that exhibits those issues?
  • What error messages are you seeing?

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 __

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Viking1726 picture Viking1726  Â·  4Comments

pavelgordon picture pavelgordon  Â·  4Comments

gigaSproule picture gigaSproule  Â·  4Comments

huaouo picture huaouo  Â·  6Comments

timothymdavis picture timothymdavis  Â·  4Comments