Home > Back-end >  IntelliJ marking mapstruct classes as having a problem, until I click them and there is none
IntelliJ marking mapstruct classes as having a problem, until I click them and there is none

Time:09-02

Maybe it's just me being unable to formulate the question in such a way as to find an answer on google. Maybe it's a common thing, maybe it's not.

All I can say is that I'm working on my fifth microservice, and all five of them have had the same exact issue.

Project view has no issue. I've even enabled Project-Wide Analysis.

But mapstruct classes (be it interfaces or abstracts), but not configs. Just classes that will eventually end up generating code. They all get a red squiggly underline.

If I don't click the class and build or run, everything is fine.

If I do a gradle clean build - everything is fine.

If I do a gradle clean to remove generated classes - everything is fine.

But no matter which of the above steps I do, the red squiggly line does not go away.
However when I double-click the class (to open it in the editor and see what the issue is) ... everything is suddenly fine. No error, no problem, no nothing. For like a minute till they get underlined again.

The gutter red line for the project view gives me no popup to suggest what the issue is. And, again, the problem view is empty.

I have no idea what to do. It's driving me nuts!

EDIT

I did find one error, in the Auto-Build tab of the IDE, it only really says:

javax.annotation.processing.FilerException Attempt to recreate a file for type [SomeMapperImpl]
    at ...
    ...
Caused by: javax.annotation.processing.FilerException: Attempt to recreate a file for type [SomeMapperImpl]
    at ...
    ...

But the error seems to be in error itself. The class was absolutely generated and everything works.

CodePudding user response:

I tried invalidating caches:

  • IntelliJ -> File -> Invalidate Caches -> tick everything -> Invalidate and Restart.

Worked like a charm.

  • Related