I completely uninstalled IntelliJ and have now reinstalled and imported my project. I imported using gradle and can see all of the files in my project present. However, when I open a file I can't find any declaration to go to by doing cmd + click. I have the Java 7 SDK setup, and I can't even go to the declaration of classes in my own project. Going to a Java core class like String or List doesn't work either. How can I enable the IDE to be able to find my classes?
I'm on OSX Yosemite, IntelliJ 2016.1.2 build 145.972.
I had this same problem, and #AniaG's solution in the comments worked for me.
Right-click src folder
Mark Directory as > Sources Root
I faced the same issue and spent almost 15-16 tiring hours to clean, rebuild, invalidate-cache, upgrade Idea from 16.3 to 17.2, all in vain.
We have a Maven managed project and the build used to be successful but just couldn't navigate between declaration/implementations as Idea couldn't see the files.
After endlessly trying to fix this, it finally dawned to me that it's the IDEA settings causing all the headache. This is what I did (Windows system):
Exit IDE
Recursively delete all .iml files from project directory del /s /q "C:\Dev\trunk\*.iml"
Find and delete all .idea folders
Delete contents of the caches, index, and LocalHistory folders under <user_home>\.IntelliJIdea2017.2\system
Open Idea and import project ....
VOILAAAAAAAAAAAA...!!
I hope this helps a poor soul in pain
I had the same issue with idea and I was trying to open a maven project but the pom files where not identified. So right clicking on the pom file and choosing "add as maven project" did all the magic for me :)
Had the same problem. But only on my own methods.
Just fixed it by invalidating cache: (File-> Invalidate Caches/Restart)
I was having similar issues in my IntelliJ mvn project. Pom.xml was not recognized.
What worked for me was right click on the pom.xml and then add as a maven project.
Most of the times there has been a problem with building the cache of the IDE, or something related.
Most probably, File -> Invalidate Caches / Restart, will resolve this problem, just let the IDE finalize it's caching.
Your source folders where your Symbols are (Classes) are need to be configured as "Content Root".
Open Project Structure: #;
Click Modules
You can configure your Content Root (Sources, Tests, Resources etc) for each module that you want to Navigate to.
Once done you should be able to navigate to your symbols.
If you see red circle on the icon of Java files, and got warning like "cannot find declaration to go to". Then you can do something below:
Right click root folder of your project/module.
Mark Directory As -> Excluded.
It works for me. in Windows 7, Intellij 2016.1.1
Right-click on your src folder and choose the option "mark directory as" --"Source root" and along with it again right-click on your project and choose "reformat code"(under this choose cleanup code too) and that will work fine.
I got this problem on Big Sur.
Solution:
File -> Invalidate Caches. After that press Option + Enter on every red field.
In my case, I just updated my IntelliJ to Ultimate 2018.2 and all of my projects suddenly cannot find the implementations and the 'src' folders - it turned out IntelliJ removed the type of project (e.g. Maven).
What I did is:
Right click on the root project > Add Framework support... > Look for Maven (in my case) > Wait to re-index again > Then it worked again.
UPDATE 2:
I have always been encountering this when I update IntelliJ (2019.1.1 Ultimate Edition).
Just click the refresh button of Maven Tab and it should re-index your current project as Maven Project:
I found this cannot find declaration to go to problem once in my Maven project. The reason for this was just that one of the sub-projects in my project did not import as maven project correctly.
None of the methods listed in this channel works for me.
However, I am able to resolve it using the following method, and I hope that it works for you too.
Right Click the pom.xml file and then select "Maven". After that, click "Import Maven Project"
Ensure that the directory which contains your compiled classes and libraries is marked as sources Root.
I too faced this issue. I've tried the solutions mentioned here. The issue seems not with the source folder.
For me the issue occurred when I installed a new version of IntelliJ, was using 2019 version moved to 2020 version.
The project got opened in the new version but the declarations were missing.
I fixed this by :
- File>Project Structure.
- Under Project Settings go to Modules. Here you should see the different project folders, for me it was not there.
- Click the + button on top and click Import Module.
- Select the root pom.xml and wait for the indexing to complete.
After the indexing is done all the declarations were working.
Importing my project (which had 3 different modules in it) - as File -> Module From Existing Sources fixed it for me.
Just run below commands
mvn idea:clean
mvn idea:idea
IDEA may ignore some of your maven dependency files. The "External Libraries" node in your project structure might be empty or incomplete.
Go to:
IntelliJ --> Preferences
Search for Maven [on the left tab] -> Ignored Files
See if there is any path on the right side that is checked(ignored) and uncheck that.
Came across the same issue and in my case (Java project), I had to include all the dependent jars in the project's libraries section.
File -> Project Structure -> Libraries
I had to add my project dependent jars in the above section (for example; project/web/lib/). After doing so, all resolved fine. I hope this will help someone.
For someone whom the above solution didn't worked.
For gradle,
File -> Project Structure
Click on Project Under Project Settings
Update Project Language level as Modules, private methods in interfaces etc.
Click OK and Import Gradle Settings
I had similar issue with Goland JetBrain and what worked for me is similar to what #user8382868 said but I only closed the IDE, renamed the folder .idea file to .idea.old and after re-opening the project everything worked.
For Java based project, this is what worked for me :-
-Download Intellij 2020.3.4 version instead of 2021.1.1
-Add configuration, plugins.
-Configure settings, Project Structure
-Right click on the root folder -> Mark Directory as -> Sources Root
-File -> Invalidate caches/restart -> Invalidate and Restart
In my case I was using a gradle project with subprojects. The reason IntelliJ couldn't find declarations was that the subprojects were not built.
After investigating why subprojects were not built, I found out that using "auto-import" was breaking the subprojects.
After importing the project from build.gradle without auto-import, it worked for me.
For what its worth, in Pycharm it is: Right click on the root folder->Mark Directory as-> Sources Root
Same Problem for Python Project!!!
I tried to make a clean new intellij project and updated everything. Tried different virtualenvs but nothing worked out.
UNTIL I uninstalled the Python Plugin + Restart IntelliJ + Intall Python Plugin + Restart IntelliJ again. I'm not sure if this is a "real" solution, but it solved my issue.
Maybe you can try something familar for Java "Plugin"/JDK?
In my case, none of the above helped. Only upgrade of Intellij from 2017.3 to 2018.2 helped.
Do not try 2018.1 as it had a bug wherein the Find files popup would not come up.
Somehow I set my Maven modules to be ignored. In the Maven tool window right click and select 'Unignore Projects'.
Then all the directories will be automatically selected.
I had the same issue.
what i did was.
Select your project >right click> go to settings> plugins > search for cucumber > and then re-bundled the plugin
and restart your intellij.
It should fix the issue.
Nothing above worked for me unfortunately. I deleted all downloaded dependencies from .m2\repository and did a mvn clean install to download them again. (Although i did not have any issues in the pom.xml at the first place)
That worked for me.
In my case, I've to open preferences:
And I went to Project -> Project Structure -> set my folder project in +Add Content Root
So now all it work fine!
I am developing a maven project using IntelliJ-14. The other day everything was correct without any problem but today when I got in the project some of my imports are not working. When I compile it is everything ok and I can run the project but autocomplete does not work and some classes appear red.
I've tried to go File-> Settings-> Maven-> Importin-> Import Maven Projects Automatically check. Already imported the project again and nothing. In external libraries classes exist.
An example of my code is here.
What else can I do to solve this?
Please help
Right click on the project-->Maven--->UpadateProject.
This may help you.
Some possible solutions since we can't tell what is actually wrong:
Delete your .m2 folder and do a reload maven project
Go invalidate "caches and restart" (File - Invalidate caches /
Restart)
If you work with other people see if they have committed something that breaks the maven build. Some times the version of jars that you have in your local maven repo (.m2 folder in your %USER_HOME% folder) is different than the one that they other devs using
Do "Reimport all maven projects"
I experienced the same problem. Before it occured, I created a package structure from within IDEA, for example "de.ulli.myPackage". Of course I expected to get the directory structure "de/ulli/myPackage". I don't know why, but actually there was a single directory named "de.ulli.myPackage" (OS Windows 7 64 Bit). Maven was able to build the project, and I even could generate classes via IDEA. But autocomplete didn't work and the classes within the package appeared red in other sources. After reparing the directory structure, everything was fine.
I'm trying to import a project on GitHub into eclipse because there are a few things I want to add to it. However whenever I add it I get a ton of errors and problems with it...
The GitHub project is https://github.com/dmulloy2/SwornGuns
I've tried adding it to eclipse and it didn't work. I then tried making a project in eclipse and then put the files in, that didn't work. I also read online that going to Configure -> Convert to Maven Project would work, and then importing the spigot.jar file that this source depends on. However that didn't work and just gives me a ton of import errors.
The errors I am getting:
That project is a maven project. A simple way is clone that project into your machine, and import it as a maven project, with File - Import - Maven - Existing Maven Project.
Eclipse will help you resolve the pom file and configure project and download necessary libs.
First, make sure you are using Luna, the most recent version.
In eclipse, File > Import > Git > Projects from Git > Existing Local Repository.
In the Import Projects from Git screen, click add, then goto the location of the cloned repository. Click open, finish, then next. Select Java > Java Project, and click next again.
At this point, there are three options.
Import existing projects
Use the New Project Wizard
Import as General Project
Pick "Use the New Project Wizard". Then, uncheck "Use Default location", and click browse. Select a folder (You probably want the location you cloned the repo to), click "Open", and give the Project a name. Click next, and make sure that the src/bin folders are setup correctly, and click finish.
Whew!
Of course, the Import from Git option was only added in Luna, so update eclipse if necessary.
I am currently working on a larger scale Maven-based project in IntelliJIdea 12.1.6 Ultimate. I have been working with IntelliJIdea since about 5 months.
An included module has dependencies on another module. The dependent module's source was also part of my project until recently. Since I removed the dependent module from my project, I get compile errors whenever I am trying to compile the source without maven.
The pom.xml of removed modules in Intellij seem to be placed onto the Settings->Maven->Ignored Files. I cant seem to remove it from there, only check or uncheck it. It's not possible to include the module again since IntelliJ will say its still under Ignored Files.
2 ways allow me to compile again: Uncheck the pom from Ignored files, which will include the module again in my project. Or delete the source of the dependent module, so my project will load the dependent module from the maven repository. But whenever I update my project from svn, the source of the dependent module is restored (I don't know why this even happens since its not part my project) and the cycle begins anew.
I googled this for a while since it gets really annoying. It became a problem with several excluded modules. I could rebuild the intellij-project from scratch but since a lot of IntelliJ settings were made (not related to the problem) I would rather solve this.
Any help is appreciated, I guess I must be missing something
A collegue who has more in-depth knowledge of maven told me the answer:
The trick is not to remove the source module from the intellij project but to remove it from maven (in the maven projects tab in intellij). Intellij will ask then to remove the source module also from the intellij project and its finally gone.
Right click on the maven project -> remove projects
Would not have guessed this makes such a difference.
Do any of these two points work for you:
NEW there might be dependency in one of your sub-modules pointing to the removed artifact. To make sure it's the situation, you may want to rename your $HOME/.m2 and rebuild the project. If this is indeed the case, just search for the dependency in your poms and delete it from sub-modules
right click on the parent pom.xml -> Maven -> Reimport
copy the project into a separate dir. File -> Import Project -> Choose newly created dir -> Choose Maven?
PS. Idea is excellent in maintaining the project structure in accordance with Maven project. Once you make a change to your pom, you need to reload the project. Idea can also automatically detect changes made to your pom.xml and apply them to project. To enable this, press Ctrl+Shift+A, type 'maven auto', choose "Importing", checkbox "Import Maven project automatically";
This may not relate directly to the OP, but...
Using IntelliJ 2016.5, to remove a Maven module and it's underlying source code and remove it as a sub-module from the parent, go to the Project Files tab, find the unwanted module and use the triangle symbol to open it, then delete the entry that represents it on disk.
Hitting Delete on the module itself will only mark it as hidden within the IDE.
I'm getting compilation errors when I open a specific class file in Eclipse. However, the class doesn't show a compilation error icon in the Project Explorer. I have enabled dependency management by right-clicking the project and using the Maven menu.
I'm using Eclipse 3.7.1 and Maven 2.2.1.
I've not seen this problem before, but I'd try performing the obligatory clean and build all on the project. I suggest making sure the following options are checked in Preferences -> Java -> Compiler -> Building:
Scrub output folders when cleaning projects
Rebuild class files modified by others
There are several good suggestions in the question linked by bdill, specifically to try updating your project configuration from the pom.
Use Package Explorer, not Project Explorer. It's a lot more reliable for Java projects.