Annotated Spring bean definitions (all valid) marked red in IDEA 9... Why?

I have tolerated this for a while since it is quite harmless, but I think it is worth asking a question. Why are all annotated Spring components marked red in IDEA 9? Any Spring annotation, such as @Component, @Controller, @Autowired, cause red bars to appear in the code inspection status gutter on the right of the editor. They, obviously, do not indicate errors, and the overall status of the class remains green.  When I move the cursor over one of those, it simply displays a tool tip: "Spring Bean". That seems completely redundant because IDEA already displays nice green Spring icons on the left side of all those definitions making any Spring wirings obvious. If I click on the red mark, it navigates me to the annotated artifact (class, property, or method.) I have Spring Model inspections enabled, and explicitly allow autowirings (marking them as Info), and I usually have auto-scanning for Spring components enabled in my applications. I repeat, there are no violations of the Spring model anywhere, all the components are properly configured, and all the necessary dependencies are present, which IDEA does a great job validating. But why the red markings that don't have anything to do with any errors?

I thought, perhaps, there was something in my configuration that I could edit, but IDEA does not give me any options to edit any settings when I select the annotated artifact. At first, it seemed like a very obvious bug - in the first EAP builds, but since this "feature" has made it into the final release, I am wondering: what's up with that? What's the idea? If this is an intended "feature", how can I disable it or change the color from red to something less alarming?  

Thanks,
Constantine

0
7 comments

Can you provide a small example?

0

Taras, please see the the attached screenshot. The red markings on the right denote the @Component annotation for the class itself, and the @Autowired properties. Note that there are no errors in the file, and the overall status is green.



Attachment(s):
Picture 1.png
0

Constantine,

please, check your "info" color for java files. it is here: "settings/editor/colors
& fonts/Java/"  and "Info" key in Listbox for current schema.
It seems your schema uses red color to highlight info messages.

Serega.

Taras, please the the attached screenshot. The red markings on the
right denote the @Component annotation for the class itself, and the
@Autowired properties. Note that there are no errors in the file, and
the overall status is green.

---
Original message URL:
http://www.jetbrains.net/devnet/message/5254609#5254609



0

Sergey, thanks for the response.

No, it is not the case of the "info" color settings for inspections. My "info" inspections are set to produce light gray marks, and you can see a few of those on the sample screenshot. I think this issue has something to do with the way Idea [mis]interprets Spring annotations, specifically. I have checked and re-checked my Spring Model inspection settings, and I am making sure that I assign error levels only to real errors, such as violations of the Spring model, missing required properties for outowirting, etc. In the cases I have described, IDEA does not complain about anything, and it does not even give a hint or a pointer back to the inspection settings (as would be in cases of "info" messages.) It puts red marks opposite the @Component, @Autowired, etc., definitions, and that's it. Clicking on those red bars brings you to the annotated entry. Note that in my inspection settings, I specifically allow the usage of the @Autowired annotation. However, it does not matter whether the "Autowired Dependencies" inspection is completely disabled or set to "Info". Th red marks remain.

Actually, I have just disabled ALL Spring Model inspections, and the red markings still remain. So, we know it is not the issue with Spring inspections. Then what is it?

Thanks,
Constantine

0

Do you have a spring facet that contains a spring xml file that uses the component-scan tag to pull in the class?
When you hover the mouse over the red error stripes in the gutter bar, what error message does IDEA show?

0

Your questions are actually answered in my original post in this thread.

Yes, auto-scanning is properly enabled, and it works. You can see the appropriate Spring short-cut icons on the left of the annotated definitions that indicate that IDEA recognizes the wirings and dependencies.  When I hover the cursor over the red bars, nothing happens when the bar corresponds to an @Autowired property, and if the bar corresponds to the class definition annotated by @Component, @Controller, etc., it pops a tool tip: "Spring Bean". D'oh... That's all. There are no error messages. No errors. The class is marked green, as you can see in the screenshot, and everything works fine. The red bars just get in a way when they are mixed with real errors in the file. And, after a while, it just becomes annoying.

0

Hello 

Your issue probably stems from the fact that you have @Configuration annotation on the class instead of @Component. Had the same issue and this cleared the "RED" warnings.

Regards.

0

Please sign in to leave a comment.