IntelliJ IDEA cannot resolve symbol when using external libraries
Hi,
I have a problem using external libraries in IntelliJ IDEA - in this case I'm demonstrating with Atlassian Jira libraries, however my problem is general - also occurred with org.apache.commons.lang.
I am working on a Groovy & Java project and I've added external libraries through Project Structure dialogue, however IntelliJ unable to resolve the classes in the .java files.
and - yes, I've already tried to invalidate cache files - didn't help.
When no external library is defined - only module "Sources" library - it fails to resolve beyond "com":
After adding the external library - either global or under Project Settings - it resolves all the way to the class but is not able to resolve the class itself:
Full resolution of the classes occurs only if I add the external libraries manually inside the project folder and marking it as one of the sources:
Am I doing this wrong, or do I understand incorrectly how the external libraries should work? I don't want to work this way since it's not sustainable - the folder will be overwritten when rebase from main git branch.
请先登录再写评论。
Can you please prepare a small project sample and upload it at https://uploads.jetbrains.com so that I could review the configuration? Please don't forget to specify the UploadID here.
Hi Egor,
Uploaded 2022_07_21_7bB5u7HRr6XZvZScT6k31E
steps I took after creating the class:
In project structure - I've added Global library with source code of Jira, I've added it to module, and I also did 'copy to project libraries'.

Same as before -
Could you clarify where did you get this dependency from?
Do you see com.atlassian.jira.component.ComponentAccessor in External Libraries section? (in Project Tool Window)
I'd recommend you try to add Maven support in your project and add dependency as per https://developer.atlassian.com/server/jira/platform/java-apis
Hi Egor,
If you mean from where did I get the library itself - downloaded from Atlassian site (requires commercial license).
I don't understand - I have a file which contains a class which I require for my projects. I don't want to add the file to my projects every time, and instead I want IntelliJ to resolve it globally since it's right there - am I missing something in how I configure this, or is this a bug?
In my view - it should work with adding an external Java library - shouldn't it?
To clarify - I am using the actual source code - .java files, not .jar
A Java library can include class files, archives and directories with class files as well as directories with native libraries .dll, .so, or .jnilib. If you have source code only you can import jira-api as a module and configure it is a dependency for test-groovy-atlassian module:
- Delete jira-api from Global Libraries, Libraries and module dependencies.
- Go to File | Project Structure | Modules | + | Import Module | select jira-api directory.
- Go to File | Project Structure | Modules | test-groovy-atlassian | Dependencies | + | Module dependency | select jira-api module.
- Save settings and try to import a class from jira-api.
Hi Egor,
Thank you for clarifying. Using the module method works.
Thanks!