I am using Intelli J as the IDE and maven(3.3.9) as my build tool. After I completed my code in Java I was trying to add junit dependency to my pom.xml but maven doesn't seem to recognize the dependency. I came across a few other related questions on this issue but on trying all possible solutions exhaustively the problem still seems to persists.
My pom.xml currently looks like:
Following are the possible fixes I tried to alleviate the issue:
Downloading Library from Maven Repository from Project Structure
Specifying the junit dependency through the Project Structure (File > Project Structure > Libraries > New Project Library (from Maven)). I searched for junit and chose junit:junit:4.11 but I get "No files were downloaded"
Makes changes in the Project Setting for Maven
I went to File > Settings > Build,Execution,Deployment > Maven and I checked Use plugin directory and changed maven to the appropriate location. It looks like follows:
Following that I also went to File > Settings > Build,Execution,Deployment > Maven > Importing and checked Import Maven Projects automatically.
Running maven
Then I also ran maven clean install which ran with success after downloading some files:
Re-importing All Maven Projects
I also re-imported all maven projects from the Maven Projects tab on the right but I end up with unresolved plugins and the an error popup saying "Failed to read artifact descriptor for junit:junit:jar:4.11" when I hover over the red-lines.
Can someone tell me anything else I might have missed if you have ever encountered the same before ?
Thanks!
Related
I have multi module maven project in intelliJ 2019.3 (Ultimate)
I am not able to get all dependencies after several tries. I tried below solutions as well
Solution 1
Solution 2
I noticed under the Maven tool same module shows twice as below
Not sure that caused the issue here.
Strangely I don't see any red lines in the any of the POMs
Provided that you can build project from command line Maven and dependencies are downloaded.
In IntelliJ IDEA please try: File | New | Project from Existing Sources action and point to pom.xml file to import project from. Then choose to delete existing project configuration.
I am trying to create a jar in IntelliJ through maven clean-compile-package. Build is sucessful but I am not getting class and packages in tha jar. Please help! I got below warning in logs:
[WARNING] JAR will be empty - no content was marked for inclusion!
maven project have default standard directory layout its documented here
if you not followed them or moved folders around, maybe changed output folder or similar action was taken, maven can't correctly decide how to include your class files.
As shown in the screenshot there is a dependency of the dl4j-0.4-examples project that is unable to be loaded by intellij.
Unable to get dependency information: Unable to read the metadata file
for artifact 'com.github.jai-imageio-core.jar': Invalid JDK version in
profile "java8-and-higher': Unbounded range [1.8
A similar problem resolved in this question
https://github.com/google/gson/issues/596
as quick fix open the pom file at your local repository and add ')'
and should looks like
91 [1.8,)
save and execute again
But in this case there is no jdk tag: so that approach can not be used.
Has anyone found a workaround to load this project into intellij?
The owners of the project have recognized this as an issue. If you would like to follow along here is the bug tracker:
https://github.com/deeplearning4j/dl4j-0.4-examples/issues/76
Update 2/28/16: The resolution: I needed to do
brew switch maven 3.3.9
There were multiple versions of maven installed on my machine but I did not know about brew switch. So some ways maven was working without doing the switch - but for this project a completely clean maven installation was required.
I create a simple sample Spring MVC project, where IntelliJ 14 by default generate a pom with
<properties>
<spring.version>4.1.4.RELEASE</spring.version>
</properties>
I change it to
<properties>
<spring.version>3.2.0.RELEASE</spring.version>
</properties>
and choose Maven -> Reimport, I can see the dependencies are downloaded to my local .m2 folder
However, when I expend lib folder, all dependencies stays with previous version:
How can I get the latest dependencies showing in \lib folder? I tried to synchronize current project, but it doesn't help this matter
UPDATE
here is my maven setting
UPDATE 2
I forget some detail, which is I create a Spring MVC project in the beginning(so I think it may not be a maven project at the moment), then I right click pom.xml and set current project to maven project.
So I think the jar files listed in \lib folder may be downloaeded via intellij for Spring MVC application, however when I set current project to maven project, it does not remove or update the jar file under the \lib folder.
You should do:
1. Choose menu File \ Project Settings..., In section Build, Execution, Deployment \ Build Tools \ Maven \ Importing, check Import Maven projects automatically. It means IntelliJ IDEA will Synchronize Maven project model and IDEA project model each time when pom.xml is changed.
2. Try closing project, restart IntelliJ IDEA, then reopen the project.
3. Check your internet connection.
IntelliJ isn't shouldn't be looking there for your Maven project dependencies. It is should be using the libraries and resources in your .m2 directory instead.
Mind you, I've left those comments struck out on purpose; depending on your configuration, you may accidentally be doing that.
This is a picture of what the Dozer project looks like. It's a Maven project which I cloned a ways back to see how it worked.
You're going to have to check your Project Structure (Ctrl + Alt + Shift + S) to ensure that the libraries that are coming through are prefixed with "Maven:".
If they are, then the files in your lib folder aren't being used by your project.
In all actuality, those are your global libraries (which you can also find under Project Structure > Global Libraries). Any project has access to them.
If that's causing a conflict, consider deleting those JARs from your global libraries. If you need them for another project, consider adding it to the project's local libraries instead.
IntelliJ downloaded the dependencies listed in my build.gradle file and they show up in the External Library, but IntelliJ fails to find them during compile. It just throws a bunch of "package x does not exist" and "cannot resolve symbol". Under the Project Structure -> Modules -> Dependencies they all show up and are listed as compile.
If I try to build it with Gradle it's successful, so it's just IntelliJ. Any ideas?
If it's important, I'm using this on a Mac.
Found the answer. IntelliJ was treating Main and Test as modules with no dependency related to the project itself and all of the library dependencies were stored at the project level.
I killed off Main and Test as modules and it sorted itself out.