Cannot find jar at libraries [duplicate] - java

I just imported a project from subversion to IntelliJ IDEA 11 - it's a maven project. But I have a problem in maven library dependencies so that I can't include all maven dependencies automatically - IDEA shows dependency errors only when I open that class/ Thats what I get here:
So I want all dependencies to be added automatically - is that possible or do I have to go through all class files to identify and add maven dependencies?!
UPDATE: After doing some modifications I found how to resolve my problem in some way. Thats what I did:
but I think logically it will not include and check new dependencies ahead?!... Is there any settings area for this in intelliJ - auto export dependencies to classpath?

IntelliJ should download and add all your dependencies to the project's classpath automatically as long as your POM is compliant and all the dependencies are available.
When importing Maven projects into IntelliJ an information box usually comes up asking you if you want to configure Auto-Import for Maven projects. That means that if you make any changes to your POM those changes will be loaded automatically.
You can enable such feature going to File > Settings > Maven > Importing, there is a checkbox that says "Import Maven projects automatically".
If that doesn't help, then I would suggest to make a full clean-up and start again:
Close your project window (and IntelliJ) and remove all *.iml files and all .idea folders (there should be one per module)
Run mvn clean install from the command line
Re-import the project into IntelliJ and pay attention when it asks you to enable auto-import
IntelliJ 2016 Update:
The Import Maven Projects automatically setting has been moved to Build, Execution, Deployment > Build Tools > Maven > Importing in your IntelliJ preferences.

Fix before IntelliJ 14
File [menu] -> Settings -> maven -> importing and uncheck "use maven3 to import project"
ref: http://youtrack.jetbrains.com/issue/IDEA-98425 (which may have a few other ideas too)
Fix IntelliJ 15+
Ran into this again, with IntelliJ 15 this time, which has no "use maven3 to import" option available anymore. The cause was that sometimes IntelliJ "doesn't parse maven dependencies right" and if it can't parse one of them right, it gives up on all of them, apparently. You can tell if this is the case by opening the maven projects tool window (View menu -> Tool Windows -> Maven Projects). Then expand one of your maven projects and its dependencies. If the dependencies are all underlined in red, "Houston, we have a problem".
You can actually see the real failure by mousing over the project name itself.
In my instance it said "Problems: No versions available for XXX" or "Failed to read descriptor for artifact org.xy.z" ref: https://youtrack.jetbrains.com/issue/IDEA-128846
and
https://youtrack.jetbrains.com/issue/IDEA-152555
It seems in this case I was dealing with a jar that didn't have an associated pom file (in our maven nexus repo, and also my local repository). If this is also your problem, "urrent work around: if you do not actually need to use classes from that jar in your own code (for instance a transitive maven dependency only), you can actually get away with commenting it out from the pom (temporarily), maven project reload, and then uncomment it. Somehow after that point IntelliJ "remembers" its old working dependencies. Adding a maven transitive exclude temporarily might also do it, if you're running into it from transitive chain of dependencies."
Another thing that might help is to use a "newer version" of maven than the bundled 3.0.5.
In order to set it up to use this as the default, close all your intellij windows, then open preferences -> build, execution and deployment -> build tools -> maven, and change the maven home directory, it should say "For default project" at the top when you adjust this, though you can adjust it for a particular project as well, as long as you "re import" after adjusting it.
Clear Caches
Deleting your intellij cache folders (windows: HOMEPATH/.{IntellijIdea,IdeaC}XXX linux ~/.IdeaIC15) and/or uninstalling and reinstalling IntelliJ itself. This can also be done by going to File [menu] -> Invalidate Caches / Restart.... Click invalidate and restart. This will reindex your whole project and solve many hard-to-trace issues with IntelliJ.

When importing the project, select pom.xml instead of the project directory. It should work.

Try to Re-Import the project from the Maven Projects panel in IntelliJ IDEA. It should download and configure all the dependencies defined in your pom.xml automatically.
If download doesn't work from IDEA for some reason, try mvn install from the command line and see if the dependencies can be fetched.
Of course all the required dependencies and any custom repositories must be defined directly in the pom.xml file.

For IntelliJ 2016-2.4 (and I believe other new-ish versions):
View > Tool Windows > Maven Projects
In the newly revealed toolbar, select Maven settings (icon of a toolset).
When this screen opens, expand the Maven menu and click 'Importing'
Here, click "Import Maven projects automatically." Also ensure that the 'JDK for Importer' option matches the JDK version you mean to use.
Click OK. Now go to the red dependency in your pom.xml, select the red lightbulb, and click 'Update Maven indices'.

What helped me:
Navigage:
Settings | Build, Execution, Deployment | Maven
Specify "Maven home directory" - the place you installed the maven

If certain maven modules are not compiling check if their pom.xml is on the "ignored files" list. In IntelliJ goto
preferences -> project settings -> maven -> ignored files
and check if the related pom.xml is ignored.

I had the same issue and tried all the answers mentioned here, none worked.
The simple solution is go to your project folder and delete all the .idea and .iml files and restart the IntelliJ ide. It works. No need to do anything with the settings.

Open IntelliJ Idea, Go to
File > Other Settings > Default Settings... > Maven (Preferences) > Importing or|
Preferences > Maven > Importing
Click on Enable Auto-import in the console.

When you create a new project you simply need to choose the option:
...
Import project from external model
Create IDEA project structure over existing external model (Eclipse, Maven...)
...
You'll find it pretty straight forward from there.
And in your case you can close your project and simply create a new one. Choose your project's directory, which will override it, making it a Maven project.

Importing Maven dependencies may not work if you import the same path several times. This may happen automatically after importing an existing maven project. I can't figure out why this happens, so I'm inclined to think it is a bug.
For example, if my project is
hibernate
src/main
src/test
the three paths may be imported as top nodes:
hibernate
src/main
src/test
If such is the case, the dependencies appear to be right, but they won't be used until you remove the superfluous paths (in this case, src/main and src/test). Once you do this, refresh and click Build > Rebuild Project. IDEA will pick up the dependencies.
A symptom of this problem is that IDEA warns you of a duplicated path when you manually check a library (second screenshot in the question).
There are several ways to re-read the dependencies in case you need it. If you go to the “Maven Projects” tab, there is a “Reimport All Maven Projects” icon at the top left of the tab. If you suspect IDEA became confused you can click on File > Invalidate Caches.

First check path Specified for User Settings file: in Settings -> Build,Execution,Development -> Build Tools -> Maven .
The field should have path of the settings.xml of your maven. Also the settings.xml should have correct path of remote repository.

Go into your project structure, under project Settings, Modules, select the dependencies table. For each dependency, change the scope from 'Test' to 'Compile'.

If in the lower right corner it says "2 processes running..." or similar, you may just need to wait for that to finish, since it may take time to download all the jars.

Reimport the project. If you install maven plugin you can use this.
Right click on the project -> Maven -> Reimport

I had a similar issue, in my case I am using a custom settings.xml which was not picked from IntelliJ.
Solution:
File > Settings > Build, Execution, Deployment > Maven: User settings file (chose here my custom settings.xml).

IntelliJ 2020.3.3
This one did it for me.
Build, Execution, Deployment > Build Tools.
Change "Reload project after changes in the build scripts":
from default "External Changes" to "Any Changes"
With this, it took a while for the project to rebuild but now I can see Maven dependencies in IntelliJ:

I ran into the problem that some subdependencies couldn't be resolved in IntelliJ 2016.3.X. This could be fixed by changing the Maven home directory in Settings > Build, Execution, Deployment > Build Tools > Maven from Bundled (Maven 3) to /usr/share/maven.
After that all subdependencies got resolved as in previous IntelliJ versions.

In my case, path for JAVA used by MAVEN was not set as JAVA_HOME as configured on the machine. Hence, it was not even trying to download the dependencies.
Steps I followed which solved this issue,
Checked for JAVA path , Settings >> Build >> Build Tools >> Importing >> JDK for importer. Pointed it to JAVA_HOME.
mvn clean install -U
Used above command to force the dependencies download.
Re imported Maven Projects

So I was also facing this problem in lots of my organisation's codebase. On addition to the answers suggested above, we can tweak around with the allocation pool memory of the jvm. This is because, the volume of the dependencies brought in large codebases may be overwhelming for the jvm for IDE to build the project completely. Hence tried increasing XMX value and it worked! Added -Xmx3072 to resolve the issue of "not building" my Java project in IntelliJ

Maven - Reimport did not work for me.
I have Spring project in STS(Eclipse) and my solution is to import project to IDEA like so:
1) File - New - Project from Existing Sources... - select directory - choose Eclipse.
2) Set Maven autoimport to true in settings.
3) Then right click in pom.xml and choose Add as Maven Project.
After this it has imported everything.

I had the similar issue with my macbook, just did a small change in pom.xml and it started downloading all dependencies:
Earlier dependencies were written as below for my windows machine:
<dependencies>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
I just removed the <dependencies> and </dependencies> tags and it started downloading all the dependencies:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
I am not sure it will work for you or not.. but worked fine for me.
Thanks

Deleting the .idea folder from the project directory, and then re-importing the project as a Maven project is what worked for me.

Invalidate Caches worked for me:
File > Invalidate Caches
Checks:
Clear file system cache and Local History
Clear downloaded shared indexes
Then Invalidate and Restart

I solved this issue by updating my settings.xml file with correct mirror config, seems that intellij will try to download meta-data from repository every time the maven module imported.

Hijacking a bit to add what ended up working for me:
Go into the Maven Projects sidebar on the right edge of the IDE, and verify that your dependencies are listed correctly under your module there. Assuming they are, just ask IDEA to reimport then (the first button at the top, looks like two blue arrows forming a counter-clockwise circle).
Once I did that, and let IDEA reload the project for me, all my dependencies were magically understood.
For reference: this was with IDEA 13.1.2

I faced the same problem and tried everything suggested which did not solve the issue, I was using Intellij version 13.1.3
Finally after spending more than couple of hours trying to fix it, I decided to try an upgraded version and opened the project in version 14.1.4 which ultimately resolved the issue. I would think this as a probable bug in the previous version.
I hope this helps!

I was able to resolve it by removing unnecessary modules from Project Settings -> Modules list.
It turns out these additional modules were created automatically by IntelliJ IDEA when I created the IntelliJ project by importing from the project folder (instead of by opening pom.xml). Then, after declaring the project as Maven project, proper modules were created, and existing modules were conflicting with them. It is also possible to exclude those modules during project creation.

In my case, one of the modules was ignored for some reason.
To resolve that: Right click the problematic module and choose "Unignore Projects".

You might be working under a company's internal network.
If so, to download or add external Maven dependencies your settings.xml file under user/<username>/.m2 folder might need to be updated.
Contact your administrator to provide the right settings.xml file and then paste it into you .m2 folder.

Related

Java and intelij idea [duplicate]

I just imported a project from subversion to IntelliJ IDEA 11 - it's a maven project. But I have a problem in maven library dependencies so that I can't include all maven dependencies automatically - IDEA shows dependency errors only when I open that class/ Thats what I get here:
So I want all dependencies to be added automatically - is that possible or do I have to go through all class files to identify and add maven dependencies?!
UPDATE: After doing some modifications I found how to resolve my problem in some way. Thats what I did:
but I think logically it will not include and check new dependencies ahead?!... Is there any settings area for this in intelliJ - auto export dependencies to classpath?
IntelliJ should download and add all your dependencies to the project's classpath automatically as long as your POM is compliant and all the dependencies are available.
When importing Maven projects into IntelliJ an information box usually comes up asking you if you want to configure Auto-Import for Maven projects. That means that if you make any changes to your POM those changes will be loaded automatically.
You can enable such feature going to File > Settings > Maven > Importing, there is a checkbox that says "Import Maven projects automatically".
If that doesn't help, then I would suggest to make a full clean-up and start again:
Close your project window (and IntelliJ) and remove all *.iml files and all .idea folders (there should be one per module)
Run mvn clean install from the command line
Re-import the project into IntelliJ and pay attention when it asks you to enable auto-import
IntelliJ 2016 Update:
The Import Maven Projects automatically setting has been moved to Build, Execution, Deployment > Build Tools > Maven > Importing in your IntelliJ preferences.
Fix before IntelliJ 14
File [menu] -> Settings -> maven -> importing and uncheck "use maven3 to import project"
ref: http://youtrack.jetbrains.com/issue/IDEA-98425 (which may have a few other ideas too)
Fix IntelliJ 15+
Ran into this again, with IntelliJ 15 this time, which has no "use maven3 to import" option available anymore. The cause was that sometimes IntelliJ "doesn't parse maven dependencies right" and if it can't parse one of them right, it gives up on all of them, apparently. You can tell if this is the case by opening the maven projects tool window (View menu -> Tool Windows -> Maven Projects). Then expand one of your maven projects and its dependencies. If the dependencies are all underlined in red, "Houston, we have a problem".
You can actually see the real failure by mousing over the project name itself.
In my instance it said "Problems: No versions available for XXX" or "Failed to read descriptor for artifact org.xy.z" ref: https://youtrack.jetbrains.com/issue/IDEA-128846
and
https://youtrack.jetbrains.com/issue/IDEA-152555
It seems in this case I was dealing with a jar that didn't have an associated pom file (in our maven nexus repo, and also my local repository). If this is also your problem, "urrent work around: if you do not actually need to use classes from that jar in your own code (for instance a transitive maven dependency only), you can actually get away with commenting it out from the pom (temporarily), maven project reload, and then uncomment it. Somehow after that point IntelliJ "remembers" its old working dependencies. Adding a maven transitive exclude temporarily might also do it, if you're running into it from transitive chain of dependencies."
Another thing that might help is to use a "newer version" of maven than the bundled 3.0.5.
In order to set it up to use this as the default, close all your intellij windows, then open preferences -> build, execution and deployment -> build tools -> maven, and change the maven home directory, it should say "For default project" at the top when you adjust this, though you can adjust it for a particular project as well, as long as you "re import" after adjusting it.
Clear Caches
Deleting your intellij cache folders (windows: HOMEPATH/.{IntellijIdea,IdeaC}XXX linux ~/.IdeaIC15) and/or uninstalling and reinstalling IntelliJ itself. This can also be done by going to File [menu] -> Invalidate Caches / Restart.... Click invalidate and restart. This will reindex your whole project and solve many hard-to-trace issues with IntelliJ.
When importing the project, select pom.xml instead of the project directory. It should work.
Try to Re-Import the project from the Maven Projects panel in IntelliJ IDEA. It should download and configure all the dependencies defined in your pom.xml automatically.
If download doesn't work from IDEA for some reason, try mvn install from the command line and see if the dependencies can be fetched.
Of course all the required dependencies and any custom repositories must be defined directly in the pom.xml file.
For IntelliJ 2016-2.4 (and I believe other new-ish versions):
View > Tool Windows > Maven Projects
In the newly revealed toolbar, select Maven settings (icon of a toolset).
When this screen opens, expand the Maven menu and click 'Importing'
Here, click "Import Maven projects automatically." Also ensure that the 'JDK for Importer' option matches the JDK version you mean to use.
Click OK. Now go to the red dependency in your pom.xml, select the red lightbulb, and click 'Update Maven indices'.
What helped me:
Navigage:
Settings | Build, Execution, Deployment | Maven
Specify "Maven home directory" - the place you installed the maven
If certain maven modules are not compiling check if their pom.xml is on the "ignored files" list. In IntelliJ goto
preferences -> project settings -> maven -> ignored files
and check if the related pom.xml is ignored.
I had the same issue and tried all the answers mentioned here, none worked.
The simple solution is go to your project folder and delete all the .idea and .iml files and restart the IntelliJ ide. It works. No need to do anything with the settings.
Open IntelliJ Idea, Go to
File > Other Settings > Default Settings... > Maven (Preferences) > Importing or|
Preferences > Maven > Importing
Click on Enable Auto-import in the console.
When you create a new project you simply need to choose the option:
...
Import project from external model
Create IDEA project structure over existing external model (Eclipse, Maven...)
...
You'll find it pretty straight forward from there.
And in your case you can close your project and simply create a new one. Choose your project's directory, which will override it, making it a Maven project.
Importing Maven dependencies may not work if you import the same path several times. This may happen automatically after importing an existing maven project. I can't figure out why this happens, so I'm inclined to think it is a bug.
For example, if my project is
hibernate
src/main
src/test
the three paths may be imported as top nodes:
hibernate
src/main
src/test
If such is the case, the dependencies appear to be right, but they won't be used until you remove the superfluous paths (in this case, src/main and src/test). Once you do this, refresh and click Build > Rebuild Project. IDEA will pick up the dependencies.
A symptom of this problem is that IDEA warns you of a duplicated path when you manually check a library (second screenshot in the question).
There are several ways to re-read the dependencies in case you need it. If you go to the “Maven Projects” tab, there is a “Reimport All Maven Projects” icon at the top left of the tab. If you suspect IDEA became confused you can click on File > Invalidate Caches.
First check path Specified for User Settings file: in Settings -> Build,Execution,Development -> Build Tools -> Maven .
The field should have path of the settings.xml of your maven. Also the settings.xml should have correct path of remote repository.
Go into your project structure, under project Settings, Modules, select the dependencies table. For each dependency, change the scope from 'Test' to 'Compile'.
If in the lower right corner it says "2 processes running..." or similar, you may just need to wait for that to finish, since it may take time to download all the jars.
Reimport the project. If you install maven plugin you can use this.
Right click on the project -> Maven -> Reimport
I had a similar issue, in my case I am using a custom settings.xml which was not picked from IntelliJ.
Solution:
File > Settings > Build, Execution, Deployment > Maven: User settings file (chose here my custom settings.xml).
IntelliJ 2020.3.3
This one did it for me.
Build, Execution, Deployment > Build Tools.
Change "Reload project after changes in the build scripts":
from default "External Changes" to "Any Changes"
With this, it took a while for the project to rebuild but now I can see Maven dependencies in IntelliJ:
I ran into the problem that some subdependencies couldn't be resolved in IntelliJ 2016.3.X. This could be fixed by changing the Maven home directory in Settings > Build, Execution, Deployment > Build Tools > Maven from Bundled (Maven 3) to /usr/share/maven.
After that all subdependencies got resolved as in previous IntelliJ versions.
In my case, path for JAVA used by MAVEN was not set as JAVA_HOME as configured on the machine. Hence, it was not even trying to download the dependencies.
Steps I followed which solved this issue,
Checked for JAVA path , Settings >> Build >> Build Tools >> Importing >> JDK for importer. Pointed it to JAVA_HOME.
mvn clean install -U
Used above command to force the dependencies download.
Re imported Maven Projects
So I was also facing this problem in lots of my organisation's codebase. On addition to the answers suggested above, we can tweak around with the allocation pool memory of the jvm. This is because, the volume of the dependencies brought in large codebases may be overwhelming for the jvm for IDE to build the project completely. Hence tried increasing XMX value and it worked! Added -Xmx3072 to resolve the issue of "not building" my Java project in IntelliJ
Maven - Reimport did not work for me.
I have Spring project in STS(Eclipse) and my solution is to import project to IDEA like so:
1) File - New - Project from Existing Sources... - select directory - choose Eclipse.
2) Set Maven autoimport to true in settings.
3) Then right click in pom.xml and choose Add as Maven Project.
After this it has imported everything.
I had the similar issue with my macbook, just did a small change in pom.xml and it started downloading all dependencies:
Earlier dependencies were written as below for my windows machine:
<dependencies>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
I just removed the <dependencies> and </dependencies> tags and it started downloading all the dependencies:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
I am not sure it will work for you or not.. but worked fine for me.
Thanks
Deleting the .idea folder from the project directory, and then re-importing the project as a Maven project is what worked for me.
Invalidate Caches worked for me:
File > Invalidate Caches
Checks:
Clear file system cache and Local History
Clear downloaded shared indexes
Then Invalidate and Restart
I solved this issue by updating my settings.xml file with correct mirror config, seems that intellij will try to download meta-data from repository every time the maven module imported.
Hijacking a bit to add what ended up working for me:
Go into the Maven Projects sidebar on the right edge of the IDE, and verify that your dependencies are listed correctly under your module there. Assuming they are, just ask IDEA to reimport then (the first button at the top, looks like two blue arrows forming a counter-clockwise circle).
Once I did that, and let IDEA reload the project for me, all my dependencies were magically understood.
For reference: this was with IDEA 13.1.2
I faced the same problem and tried everything suggested which did not solve the issue, I was using Intellij version 13.1.3
Finally after spending more than couple of hours trying to fix it, I decided to try an upgraded version and opened the project in version 14.1.4 which ultimately resolved the issue. I would think this as a probable bug in the previous version.
I hope this helps!
I was able to resolve it by removing unnecessary modules from Project Settings -> Modules list.
It turns out these additional modules were created automatically by IntelliJ IDEA when I created the IntelliJ project by importing from the project folder (instead of by opening pom.xml). Then, after declaring the project as Maven project, proper modules were created, and existing modules were conflicting with them. It is also possible to exclude those modules during project creation.
In my case, one of the modules was ignored for some reason.
To resolve that: Right click the problematic module and choose "Unignore Projects".
You might be working under a company's internal network.
If so, to download or add external Maven dependencies your settings.xml file under user/<username>/.m2 folder might need to be updated.
Contact your administrator to provide the right settings.xml file and then paste it into you .m2 folder.

Why does IntelliJ give me "Package doesn't exist" error?

I'm trying to use the barbecue barcode printing library. I have successfully added the library to IntelliJ through project structure add library. Then I imported the packages and wrote the methods, which gave me no error. The packages were available in the class.
But when I compile it gives me the error:
error: package net.sourceforge.barbecue does not exist
How can this be?
I'm coding in ubuntu, is there any other place to which I have to add the library?
Just reimport didn't work. Following worked for me.
File -> Invalidate Caches /Restart
Then
Build -> Rebuild Project
That will reimport maven project.
Note : You need to invalidate the cache AND ALSO rebuild the project.
I tried to "Maven > Reimport" but the only thing that actually fixed it was to close the project, delete the .idea directory, and reopen the project.
None of the 13 existing answers worked for me. However, I could resolve the issue by first removing all modules:
open File > Project Structure...,
go to Modules tab,
select all modules and press the remove button,
then removing all remaining Maven modules from Maven tool window:
select all modules,
right click on them,
press Remove projects,
and then adding them again in Project tool window:
right click on root pom.xml,
press Add as Maven project,
now unignoring any ignored modules from Maven tool window:
select all ignored (grey) Maven modules,
right click on them,
press Unignore,
and finally rebuilding using Build > Rebuild project. This assumes that a mvn clean install already happened.
Right click your project / Maven (at bottom) / Reimport
Edit, much later: I also saw this happen much more frequently when I had the Clover plugin installed. Drop that plugin like a bad habit!
In my case the only thing that worked is:
mvn idea:idea
The good thing is that you don't have to delete .idea folder or .iml files and loose all configuration. Everything will be preserved.
(Possibly something like gradle idea works for gradle too).
menu -> build -> Rebuild Project
has worked for me
(Invalidating caches without this step doesn't help)
I did re-import all maven projects. This worked for me.
If you added a library to the project structure (rather than via maven, that would be different), be sure it is included as a dependency for the relevant module.
Project Structure -> Modules -> Dependencies
It's a very annoying problem which happens quite often. Especially after switching to a different git branch. It wasted me way too much time to troubleshoot this kind problem. I have tried all the methods above. But I can't find a reliable way. Here I just summarize those steps which could help in my situation. Jetbrains, please fix this issue to save your customer's precious time.
Make sure do a success command line build (If UT failed, please ignore UT by using -Dmaven.test.skip=true.
In the "Maven Projects" view, try to use "reimport" all the maven project.
In the file menu, use "Invalidate Caches"
Delete .idea folder, basically create the workspace from scratch. (That's the only reliable way can solve this issue)
In my case the problem was that there was a different repository directory configuration in IntelliJ and in settings.xml file.
Check both repository directories are the same:
IntelliJ (File > Settings > Build,Execution,Deployment > Build Tools > Maven )
settings.xml
(usually in C:\Users\myuser\.m2 or /home/myuser/.m2)
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<localRepository>C:\Users\myuser\.m2\repository</localRepository>
...
</settings>
After fixing directories run:
Generate Folders and Update Sources for All Projects
Reimport all maven projects
Tried all the above approaches, didn't work.
Finally running maven clean install solved it!
Quit IntelliJ, remove every .idea directory:
rm -Rf **/.idea/
and restart.
Invalidate Caches/ Restart and then Build -> Rebuild Project helped for me
I tried all appreciated answers and none of them solve my problem!
According to Intellij community, there is a bug with Maven builds in 2020.1 and 2020.1.1 versions: https://youtrack.jetbrains.com/issue/IDEA-237320?_ga=2.235486722.203129946.1591253608-322129264.1584010541
Please try to run on 2019.3.4 version (Its worked for me from the first time)
You can download from here
https://www.jetbrains.com/idea/download/previous.html?_ga=2.190043688.203129946.1591253608-322129264.1584010541
Similar to cvdr. Too high a Java version can be the problem.
A collegaue just have this problem with multiple java sources in our test project. She had just updated to a later Intellij and when we investigated none of the rebuild options worked but Intellij seemed to have 'bumped' the project Java settings to Java 11 (I guess it takes highest installed version on upgrade install?) Setting it back to Java8 and the project compiles successfully.
Go File>Project Structure > Project Settings > Project and select the right ones in the drop downs.
I got this error after I changed pom, and I fixed it by execute:
mvn idea:module
it works for me
Here is a solution worked for me:
Disable the "Use --release option for cross-compilation like the following in intellij idea:
got Settings -> Build,Execution,Deployment -> Compiler -> Java Compiler and disable:
Use '--release' option for cross compilation(java 9 and later)
As someone who only occasionally needs to do Java work, this was very annoying. Inevitably, packages would have been added since the last time I ran our server inside IntelliJ and it would fail to build. I found what seems to be an easier solution: just don't build within IntelliJ. Build from the command line via Maven, then make sure that the run configuration does not list Build as a "Before launch" task.
I tried
"Maven > Reimport"
Deleting the .idea directory, and reopening the project.
File -> Invalidate Caches/Restart then Build -> Rebuild Project
Deleting what is inside local .m2 folder, and downloading dependencies again.
Running mvn idea:idea in Maven console (Though this command is obsolete, I had to try.)
in different combinations.
But going from Intellij 2020 version to 2019 solved my issue.
I had this problem in IntelliJ 2020.3 and tried the invalidate cache option and rebuild, but the problem persisted. The only thing that fixed it was to rename the package and rename it back to what it was originally.
I had the same problem and it was fixed for me by changing the "Maven home directory" in Settings from "Bundled" to my locally installed maven. Perhaps this triggered some kind of refresh somewhere since I had not changed this setting for months without any issue.
What happens here is the particular package is not available in the cache. Resetting will help solve the problem.
File -> Invalidate Caches /Restart
Goto terminal and build the project again
./gradlew build
This should download all the missing packages again
If you are trying the suggested ways and still no chance, be sure about your order:
Delete your .idea/
Invalidate and Restart Cache afterwards
Import maven projects from your maven tool
If you did not invalidate and restart cache just after deleting your .idea/, Intellij keeps generating it and that was keeping error in my case.
I had the same issue with my unit tests. I created tests on my master branch and early everything worked well, no matter what branch I was using. But when I switched again to master branch, tests did not work anymore.
What helped me was to:
close intellij -> delete .idea file from directory -> open project again by pom.xml (idk if it matters what way you open the project, but first time when I tried to open it normally by intellij, it still dit not work) -> reload all maven projects from right menu -> rebuild project and that's it, everything works now
I had the same problem. I fixed it by applying the android-apt plugin https://bitbucket.org/hvisser/android-apt
Maven reimport, rebuild and invalidate caches did not work. I solved it by opening a terminal and executing maven clean install in the root folder project. (IntelliJ was opened and I was able to see the IDE updating and triggering reindexation while maven was doing his job)
The above solutions didn't work for me. I had to add the dependency explicitly in the pom.xml.
Just add your jar under resources/library and then add it as a dependency in your pom.xml like:
<dependency>
<groupId>your-jar-group-id</groupId>
<artifactId>artifact-id</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/library/name-of-jar.jar</systemPath>
</dependency>
Try this out if none of the above work.
Delete your .idea/
Invalidate and Restart Cache afterwards
Re-import project
If you do not want to destroy .idea, you can try :
open Project Structure > Modules
unmark the java folder as a source folder
apply / rebuild
then mark it again as a source folder
rebuild
In case you're facing very weird "unable to resolve java, sun packages problem", try the following:
Open Project Structure and change Project SDK to another version, example: java 8 -> 9; 11->13, etc, and wait until it re-index all jdk's jars. Switch between jdks with same version may not work! (Ex: jetbrains jdk11 -> openjdk 11)
Open a new project (or create a empty one); pause new project's indexing; close the old one; start indexing; open the old project and pause the new project's indexing and wait.

IntelliJ IDEA not recognizing classes specified in Maven dependencies

I have a project in IntelliJ IDEA which was created with Maven. I then specified a set of dependencies and external repositories in the Pom.xml file.
The project builds fine on command line if I do mvn install. When I open any of the code files in the IDE though it says all the classes handled by Maven dependencies aren't recognized - as it would for a normal project if I never added the required JARs to the build path.
I know in my Eclipse Maven projects (rather than IntelliJ) it usually shows an extra directory on the left which says "Maven Dependencies" and lists the JARs pulled in via maven. I don't see that here. What am I doing wrong?
Here's what my screen looks like:
Right click on the pom.xml -> Add as Maven project -> Reimport
For some reason re-import did not do the trick. After looking at this:
http://www.jetbrains.com/idea/webhelp/maven-importing.html
I set auto-import and then the problem went away though; hopefully it helps someone else. Thanks for the ideas everyone :).
After installing IntelliJ IDEA on a new computer I found myself with the same issue.
I had to update the remote maven repository. (Settings > Maven > Repositories)
Both local and remote repos needed to be updated. The remote one wasn't updated ever before this. After a restart everything worked fine. You might have to reimport your project.
You could go to:
File > Settings > Build, Execution, Deployment > Build Tools > Maven
and check if your pom.xml is not in the "Ignored Files" list.
I was running into similar issues. For me it ended up being that I was importing the project incorrectly. I had been doing
import project
<navigate to existing project and click top level directory>
follow the wizard
What solved my maven problems was to do
import project
<navigate to existing project and click the pom.xml
follow the wizard
For me File>>Invalidate Cache/Restart>>Invalidate and Restart worked in IntelliJ
Idea cannot download all dependent jar packages using maven,try the following operations:
mvn -U idea:idea
then all the dependent jar packages are download from the maven repository
A simple reimport and/or update of the repositories via Intellij did not do the trick for me.
Instead I had to delete the complete ~/.m2/repository directory and let maven sort everything out by itself. Afterwards Maven -> Reimport finished it off.
I've encountered a similar issue after refactoring my maven project into different modules. Re-importing on it's own usually doesn't work, but I've found that deleting the .iml files and then re-importing usually does the trick.
Ran into the "same" issue some days ago. It might not be related as my issue was more specific to Spring boot but as I was struggling with it and tried every solution on this post I'm going to share my experience.
What I was trying to do is to add one of my spring boot app into another project as a maven dependency. The dependency was resolved but I couldn't access my classes.
When no packaging is declared, Maven assumes the default packaging is JAR.
The JAR generated by the Spring Boot Maven Plugin overrides the default one generated by Maven.
The solution was:
The solution that we found is to generate another JAR which will be used as a dependency to be imported from other projects.
The full article which helped me solve my issue.
Hope it helps someone.
For reasons I don't understand, in my case, I needed turn on setting "Always update snapshots" in Build, Executions, Deployment > Build Tools > Maven.
That made IntelliJ redownload dependencies and make it work.
In my case the problem was that the project was in maven2 while intellj was configured for maven3. Switching to maven2 in settings solved the problem
Might be useful to others that were still stuck like me.
None of the suggested fix worked. Actually, not before I fixed my main problem which was the installation location of maven.
In my case, I did not use the standard location. Changing that location in the maven settings (Settings/Maven/Maven home repository) did the trick.
My 2 cents.
Cache is causing problems! Make sure to do the following:
In your terminal, go to project/module:
mvn clean install
In your IntelliJ:
File > Invalidate Caches > Invalidate
Right click on project/module > Maven > Reimport
For my case I should have checked the work offline
Go to File>Settings >Build, Execution, Deployment >Build tools>Maven
Then check Work Offline
Worked for me:
mvn -U idea:idea
Since mvn -U updates the dependencies, check what mvn -U does: https://stackoverflow.com/a/26224957/6150881
Before this I have tried following steps but these have not helped:-
Deleted .idea and .iml file
Invalidate cache and restart
Maven -> Reimport .
This happened to me when I had mistakenly set my IntelliJ to power saving mode. Power Saving mode is displayed by battery icon with half empty charge. Disabling that fixed the problem.
This also happened to me after upgrading Intellij to 1.4.15. I tried to re-import the whole project with same result, but enabling Maven Auto Import did the tricks.
Looks like there are several, valid reasons why intelliJ would ignore a pom file.
None of the previous answers worked in my case, so here's what did work, in case someone else runs into this issue:
In this example, module3 was being completely ignored by IntelliJ. The pom.xml in that directory wasn't even being treated as a maven pom.
My project structure is like this:
myProject
module1
module2
module3
BUT, my (simplified) pom structure is like this:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>devs</groupId>
<artifactId>myProject</artifactId>
<version>0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>myProject</name>
<modules>
<module>module1</module>
<module>module2</module>
<modules>
<profiles>
<profile>
<id>CompleteBuildProfile</id>
<modules>
<module>module3</module>
</modules>
</profile>
</profiles>
</project>
To fix this, I modified the root <modules> element to add in module3 temporarily.
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
<modules>
Next re-import the root pom, and IntelliJ will add the module.
When that's done, revert the pom. IntelliJ will ask if you also want to remove module3 from the project structure. Click No.
Bam! Done. Module3 works and I can run my Integration tests from IntelliJ again :D
The problem was caused for me by selecting the project directory to be Imported when first starting IntelliJ rather than the pom.xml file for the project.
Closing the problem project and then following the Import process again but choosing the pom.xml resulted in a fully working project in the IDE.
For me the problem seems to be a conflict with the maven helper plugin (https://plugins.jetbrains.com/plugin/7179?pr=idea).
I disable it, and it works again :)
Go to
File > Settings > Build, Execution, Deployment > Build Tools > Maven
and check the Maven home directory. This should be the same maven installation used for command line
For me, what did the trick was to add the dependencies in File > Project Settings > Modules > Dependencies.
Just delete your project's .idea folder and re-import your project in IntelliJ.
If you have any dependencies in pom.xml specific to your organisation than you need to update path of setting.xml for your project which is by default set to your user directory in Ubuntu : /home/user/.m2/settings.xml -> (change it to your apache-maven conf path)
Go to -> intellij settings -> build,Execution, Deployement -> Build Tools -> Maven -> User settings file
Restart, Invalid caches, outside building, none worked for me.
Only Reimport worked finally. For others sake, putting it as answer:
Right click the project > Maven > Reimport
While importing a New project :
1.To identify all the modules in a project as maven modules:
File --->New Project Settings -->Build Execution deployment -->build tools --> maven ---> importing ---> enable "search for projects recursively"
Option1: Right-click on the main project folder => Add Framework Support => Check Maven option
Option2: right-click on the pom.xml file and click on "Add as a maven project"
This happened when I was upgrading from Java from 8 to 11 and Spring version. All the dependencies in the maven section disappeared as if no pom file existed. Was able to find the issue by doing
mvn clean
It showed me that one of the dependencies was missing version tag and it needed one.
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>
After adding version to the above dependency it started showing up all the dependencies under maven section.
In my case the my maven home path was pointing to Bundled Maven 3 instead of where my .m2 folder was located, fixed it by going to File > Settings > Build, Execution and Deployment > Maven > Maven home path and adding C:/Program Files/apache-maven-3.5.4

IntelliJ inspection gives "Cannot resolve symbol" but still compiles code

Platform: IntelliJ Community Edition 10.0.3
SDK: jdk1.6.0_21
OS: Windows 7
So I have a strange situation with IntelliJ that has me completely stumped. I setup a Maven project and add log4j as a dependency in the pom.xml file. The IDEA inspections run fine and my unit tests all compile and run.
I then added hunnysoft's jmime library to my local maven repository using the mvn install:install-file as follows.
mvn install:install-file -Dfile=jmime.jar -DgroupId=jmime \
-DartifactId=jmime -Dversion=3.1.1e -Dpackaging=jar
Maven installed the jar file just fine into my local repository.
I then went into IntelliJ's Settings => Maven => Repository Services and Updated my local repository (so that IntelliJ would reindex the repository contents).
Finally, I added the following dependency to my pom.xml file (just above the log4j dependency).
<dependency>
<groupId>jmime</groupId>
<artifactId>jmime</artifactId>
<version>3.1.1e</version>
</dependency>
I now create a new class as follows:
package com.stackoverflow.question;
import org.apache.log4j.Logger;
import com.hunnysoft.jmime.ByteString;
import com.hunnysoft.jmime.Field;
import com.hunnysoft.jmime.FieldBody;
public class StackOverflowQuestion {
public Field create(String name, String text) {
Logger.getLogger(getClass()).debug("create entered");
FieldBody body = new FieldBody();
body.setText(new ByteString(text));
Field field = new Field();
field.setFieldName(name);
field.setFieldBody(body);
return field;
}
}
Now for the weirdness. IntelliJ's intention mechanism picks up and recognizes the Logger import in the maven pom file just fine. However, for all of the hunnysoft imports it reports: "Cannot resolve symbol 'ByteString/Field/FieldBody'", BUT Build => Compile 'StackOverflowQuestion.java' compiles everything correctly and the unit test I created for this class runs fine (though the intentions mark the call to create() as a problem area too).
So somewhere, somehow IntelliJ is ignoring the jmime.jar file for the intention subsystem. I'm confused because the log4j dependency works fine and everything compiles and runs fine. F12 ("Go To Declaration") works on the Logger import, but breaks on all the jmime imports.
Oh, one other thing, if I go to the 'Packages' view in the "Projects" window the "com.hunnysoft.jmime" package appears and I can see ALL of the classes I imported in the code snippet above under "Libraries". Removing the above dependency from the pom.xml file causes this package to disappear and the compilation breaks.
It appears that the inspection's classpath is broken, but there does not seem to be a setting for this anywhere in the Settings => Intentions | Compiler areas (not that I expected any such settings, I believe the IDEA should already know the correct classpath based on the pom file and JDK).
As a final experiment I created a brand new standard J2SE application project (without using maven) and added the jmime.jar file directly to the project as one of its libraries. I run into exactly the same problems as described above in this new project.
Here is the MANIFEST.MF from the jmime jar file.
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.4
Created-By: 10.0-b23 (Sun Microsystems Inc.)
Name: com/hunnysoft/jmime/
Sealed: true
Specification-Title: Hunny JMIME
Specification-Version: 3.1.1
Specification-Vendor: Hunny Software, Inc.
Implementation-Title: com.hunnysoft.jmime
Implementation-Version: 3.1.1E
Implementation-Vendor: Hunny Software, Inc.
I don't see anything unusual in this jar file.
My best guess is that perhaps the problem might be a missing dependency issue. But AFAIK jmime is supposed to be self contained (JarAnalyzer doesn't come up with anything, but I'm not sure it would if a dependency jar is missing).
So, anyone have any IDEAs?
First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.
In some weird cases compiled classes may report wrong info and confuse IDEA. Verify that the classes from this jar report correct names using javap.
The following trick resolved this issue for me:
Right click on the code editor
Hover on Maven and expand
Click on Reimport
My idea version is 12.0.4
None of the solutions above worked for me. What did was removing the main.iml file manually and it suddenly worked.
This was mentioned in another answer to this same question here, but this alone fixes this for me. I do all my builds in a separate terminal, outside of IntelliJ. So the cache's need to have the proper permissions set for the IntelliJ app to read them.
Run it from the project's root folder.
$ mvn -U idea:idea
For Gradle users:
You may need to synchronize your project with your build.gradle file.
You can right-click on your gradle file under the Project pane to do this, but that didn't seem to do anything for me (I suspect a bug in my version). You'll know if this happens because it wont' kick off any IntelliJ tasks that you will be waiting on. Instead, open up the Gradle Tool pane, then click the synchronize (refresh) button. This worked for me where invalidating the cache and restarting did not.
My own circumstance: I was using a Scala project with Gradle and had to do this.
One extra step, when I did File -> Invalidate Caches and restarted the IDE, open a project. It popped up a toastbox on the top-right asking me whether to enable auto-import and that solved the problem.
Inconsistent/duplicate module names in project structure was causing this issue for me.
Go to File -> Project Strucutre -> Modules
In Click on modules which have red underline
Got to "Dependencies" tab
Make sure the dependencies which are red actually exist in dependency list. If not, rename them to match existing dependency names
This can happen when IntelliJ doesn't shut down properly and thus cannot properly save renamed module names.
Another thing to check: Be sure that dependencies are not duplicated. In my case I found that a module exhibiting this behavior was misconfigured as follows: it had a dependency on another module, and it had a dependency on a jar produced by that other module. This meant for every symbol referenced in duplicate, and was ambiguous.
Has a fixed been published? Appears issue originally affected v11/12 due to a "Compiler overhaul" back in 2013. With discussion on related issues in Jira up to end of 2014.
http://youtrack.jetbrains.com/issue/IDEA-98425
Also on Jira IDEA-98425 was marked fixed but unverified (on v12.0.3). None of the following work-around helped resolve this "Unable to Resolve Symbol" issue with Version 13.1.1 on Windows
a. Delete .IdealIC13 folder (Then, File \ Invalidate Caches / Restart)
b. From Maven Projects window,
b.1 mvn -U idea:idea –〉Executing this maven goal suppose to reload the dependencies. This works prev, but since last FRI, executing this maven goal failed as it tried to recompile the project (Of course it fails as "Unable to resolve Symbols", that's what I am trying to fix by running this command in the first place) mvn -version — shows maven version referenced 3.2.5 and that it's working
b.2 Simply right click project, and Reimport
b.3 File \ Invalidate Caches / Restart
c. Tried both Enable & Disable this setting: File -> Settings -> Maven -> Importing -> "Use maven3 to import project"
d. Settings \ Maven \ Multiproject build fail policy = Fail at end (instead of Default)
Nothing works. What's happenning to IntelliJ support on Maven.
https://youtrack.jetbrains.com/issue/IDEA-99302
From JetBeans release history, https://www.jetbrains.com/company/history.jsp
IntelliJ v14 NOV 2014
IntelliJ v13 DEC 2013
I'd assume v12 fixed (although unverified) would be incorporated in subsequent releases. Any one having similar problems with which IntelliJ version? Please share your experience. IntelliJ maven support seems broken.
Press "shift" two times > "Reimport All Maven projects" always works for me.
None of the other answeres worked for me. My imports were not being resolved because IntelliJ pointed to wrong .m2 file.
IntelliJ Version: IntelliJ Idea 2018.1.5
My location for the .m2 directory was pointed to the wrong path. All I did to fix it was re-point IntelliJ to the right .m2 directory and update it.
First, go to: File->Settings->Build, Execution, Deployment->Build Tools->Maven
I had to change the User settings file: and the Local repository: to the correct location of my .m2 directory.
After this go to: File->Settings->Build, Execution, Deployment->Build Tools->Maven->Repositories
and click the Update button.
I'm jealous of all of you who resolved through File / Invalidate caches. I just spent hours trying everything on this question and a few others from around the web.
The magic menu item didn't do it for me so I invalidated the caches myself by nuking %USERPROFILE%\AppData\Local\JetBrains\IntelliJIdea2020.3\caches
Once I did this and restarted IntelliJ (2020.3), the indexes were rebuilt and my errors went away.
My Project Structure:
src -> main -> scala -> mypackages
What worked:
Right click on the scala folder, and click "Mark Directory as Sources Root".
I had problem with Maven Importer JDK - somehow it switched itself to JDK 11, but Maven Project reload worked only with JDK 8.
Update 2022
IntelliJ 2022.1 has an interactive, step-by-step process File -> Repair IDE. It leads you through 5 steps in sequence to try and resolve this problem for the current project before invalidating the caches for all projects. From the IDEA documentation:
Refresh Project Indexes
Rescan Project Indexes
Reopen Project
Drop Shared Indexes
Reindex Project
Invalidate Caches and Restart
Steps 1- 3 fixed it for my project.
In v2022.3 and the new UI, this setting is now in File -> Cache Recovery -> Repair IDE. You can also select an individual step from there.
If your maven project is a multi-module project, check if some of the modules are ignored by intellij.
Click on View -> Tool Windows -> Maven Projects, and check if some modules are ignored(Ignored modules are in grey, e.g. gs-multi-module in the following image).
Right click on the ignored module and choose Unignore Projects.
Then wait for intellij to finish indexing, after which it will work.
For Gradle projects:
Exit IntelliJ IDEA
Delete the <problematic-project-root>/.idea directory
Delete the <problematic-project-root>/.gradle directory
Delete all .iml files in <problematic-project-root>
windows command prompt: DEL /S /Q *.iml
linux: find . | grep -e .iml$ | xargs rm
Re-import the project into IntelliJ IDEA with Gradle
In IntelliJ IDEA 2020.3, select:
File > Invalidate Caches / Restart... > Invalidate and Restart
When prompted with Download pre-built shared indexes:
don't import the shared indexes: close the dialog or choose More actions > Don't show again
Yes, sounds like you have to create libraries containing the JARs you need and add them as a dependency in your module.
For another alternative.
I got this problem also when I used JDK7_07. I tried all answers here (except deleting IDEA System Directory). But, I still got the problem. So what I did it is:
Install newest JDK (it was JDK7_45), and set the Intellij's JDK to the new one, and it works.
Re-importing the project worked for me.
Right Click on Project -> Maven ->Reimport
when I did File -> Invalidate Caches and restarted the IDE,open a project. It showed a dialogue on the top-right "Maven changes detected" and gave an option to import and enable auto-import. Even after importing the project here, I had the same issue. The above step solved the problem.
Suggested solutions did not work. I had to unignore several projects, by right clicking on the pom => maven => unignore project.
Then after a
mvn clean install -T 6 -DskipTests
in the console, IntelliJ was happy again. No idea how the projects became ignored...
Sometimes, I just open project structure, and click project, then choose a SDK version.
In my case, I am trying to open a spring boot project from IntellijIdea got the same issue like unable to import all spring related files.
Then I did:
File -> Close Project -> Import Project -> Import from external model -> Choose Gradle -> Next -> Select the project from file location -> Finish
Now everything working fine as expected.
I have seen many answers here but I finally found this solution. It may use for someone like me.
I just had this issue and it would just not go away. I eventually wiped out the IntelliJ config directory in ~ and rebuilt my IntelliJ project from scratch. (This only took about 15 minutes in the end, compared to spending an hour trying to work out problems with cached files, etc.)
Note that my guess is that the initial problem was caused by something like javathings.blogspot.com/2009/11/too-many-open-files-in-intellij-idea.html (NB: as of 2018, that link is dead, but archive.org has a copy of the page from around when this answer was first written -ed.) or a disk space/memory issue causing Java to crash. IntelliJ seemed to just get corrupted.
After invalidating my cache and restarting; and confirming my maven settings were okay, I was still seeing "Cannot resolve symbol" for a module that I definitely had set as a dependency. Turns out I had it set to the wrong scope.
You can check by right clicking on your module and selecting Open Module Settings. Click the dependency tab and verify that the scope for your un-resolvable dependency is set to Compile.
Open "Settings"
Search for "Maven"
Click on "Ignored Files" under "Maven"
Uncheck the pom.xml files contains the missing dependencies
Click "OK"
Click File -> Invalidate Caches/Restart...
Click "Invalidate and Restart"
mvn idea:idea worked for me. Found it here. Spent more than an hour, hope it helps someone
In my case, my project was using Lombok and I was missing the Lombok Plugin in IntelliJ. After installing it everything worked fine.
I tried
File -> Invalidate and Restart
which did not worked for me.
Solution that really worked :
Project Structure -> Modules -> select target folder -> Right click generated-sources and select sources -> Apply -> ok

In IDEA, after adding a dependency in maven, my artifact always show's the library needs to be 'fixed'

So every time I add a dependency to a library using maven in my pom.xml, it doesn't get deployed until I go to module settings and then click on 'fix'.
This happened when I added freemarker.
Why doesn't IDEA do this for me? Am I missing a step?
Not sure about previous versions but with IntelliJ 9, IntelliJ shows me a Import Changes link when I modify a pom.xml and also offers to Enable Auto-Import:
alt text http://www.imagebanana.com/img/emcut3ku/screenshot_008.png
The auto-import option is also available from the Maven Integration dialog: File > Settings > Maven > Importing > Import Maven projects automatically.
IDEA stores all of your module's dependencies in either a .iml or .classpath file (based on your preference).
When you change the pom.xml file, it needs to resolve the new set of dependencies (Re-import) and update the file accordingly. I can only imagine that they don't do this automatically for you because they can never really know when you are done working with the file, and causing resolution of dependencies to start while you're still typing would make working with pom.xml from within idea very irritating.
AFAIK, you're doing it right. In my version of IDEA, I see a "re-import" button that appears in the pom file editor (which saves a couple of clicks)... or you can go to the "Maven Projects" window and click the "Re-Import Maven Projects" button, but these should do the same thing as your "Fix" button in the project settings.
The original question referred to a library that wasn't deployed -
IntelliJ uses artifacts to deploy build output and required libraries to application/web servers, and currently those can include a constant list of dependencies. Clicking the "fix" simply adds module dependencies to the artifact, if they weren't already there.
Since in most use-cases this is 1:1, i.e. artifacts contain all module dependencies, I have opened an feature issue for it:
http://youtrack.jetbrains.com/issue/IDEA-99458

Categories

Resources