2

My class has the following annotations:

@Service
@AllArgsConstructor
@RequiredArgsConstructor(onConstructor_ = @Autowired)

IntelliJ marks the class with the following error (not warning): "Class doesn't contain matching constructor for autowiring"

Regardless of the error the code compiles and runs without the problem.

I found out that the similar issue (although not with Lombok generated contructors) was an IntelliJ bug, but it's been fixed few years ago.

Based on the above I believe it's an IntelliJ issue as well (I'm using 2019.3.4 Ultimate version).

Any idea what can be done to stop this error from occurring?

Chanandler Bong
  • 403
  • 1
  • 11
  • 23
  • Might not solve your problem, but you don't need the onConstructor argument anymore. @autowired is no longer needed on constructor params in recent versions of spring https://docs.spring.io/spring/docs/4.3.x/spring-framework-reference/htmlsingle/#beans-autowired-annotation – Andrew Wilkinson May 07 '20 at 13:43
  • @Andrew Wilkinson That's true if you have only one constructor in class. However in my case I need these two constructors. – Chanandler Bong May 07 '20 at 15:07
  • Try version from https://www.jetbrains.com/idea/download If issue remains file a bug at https://youtrack.jetbrains.com/issues/IDEA with a sample project if possible. – Andrey May 07 '20 at 16:13
  • The [IDEA-175127](https://youtrack.jetbrains.com/issue/IDEA-175127) issue looks related. – Andrey May 07 '20 at 16:14
  • The underscore does not seem right according to the api https://projectlombok.org/api/lombok/RequiredArgsConstructor.html – Toerktumlare May 07 '20 at 17:09
  • @ThomasAndolf Why exactly? It's described there in the JDK8 part. – Chanandler Bong May 08 '20 at 07:18
  • must have not gotten my morning coffee when i wrote that comment – Toerktumlare May 08 '20 at 07:29
  • @Andrey No change on the newest available Idea version with the newest Lombok plugin. I'll try to create some sample code. If I'll be able to reproduce it there (which I expect will happen) I'll file a bug. – Chanandler Bong May 11 '20 at 12:29

0 Answers0