Reasons and solutions for IDEA project directory or class name to turn red

Phenomenon:

When I modified part of the code and wanted to upload it, I found that some class names/method names were red, but they could be compiled.
The class name turns red because you installed a version control tool (such as Git, SVN, etc.), updated the code, and did not submit it. It serves as a reminder and does not affect the actual function.

Remedy:

Method 1:
Click on idae’s File > Invalidate Caches / Restart to clear the cache and restart, then wait for the restart of idea to complete and find that the class with the red name can be recognized (I tried it, but it didn’t work out) Method 2: Click file —
>
setting —>version control
Click the plus sign: add a project directory, and change the project to none
insert image description here
PS: Using this method, the project directory and class name are indeed not reported in red, but the shortcut keys such as submitting code and updating code in the IDEA function bar are gone. (This method treats the symptoms but not the root cause)
Method 3:
Continue to choose to submit the code on Git, find the red classes in Unversioned Files, etc., and check and submit as shown in the figure. After submitting the code, these files will no longer report red .
insert image description here

Guess you like

Origin blog.csdn.net/yzq199902/article/details/126055801
Recommended