I am not quite sure what has happened to my IntelliJ recently but any new projects created or checked out from a repo are unable to resolve the dependencies from maven.
Resulting in lots of unresolved class symbols.
Interestingly projects that have already existed work fine and IntelliJ can resolve the dependencies imported by Maven.
So something has happened within the space of the last two weeks that has caused this issue. I haven't touched the Intellij config
This is what I have done to troubleshoot:
clear cache in intellij
mvn clean and install
reimport through maven on intellij
download sources and documentation
remove maven pom and re-add it
checked m2/repository cache, which contains the libraries
IntelliJ version - 2018.2
Any ideas?
Related
I'm using IntelliJ IDEA Community 2020.2.3.
My project is built around Kotlin 1.3.30 and Java 11.
I've upgraded one of my dependecy to java 11 too, and after that, the IDE shows the dependency under "External Libraries", it build the app without errors, Maven build it from terminal without error, but the IDE shows unresolved references on each occurrency of the classes, functions and imports of that library.
I already tried to empty the cache or deleting idea files and importing again the project, but none of those worked.
Any tips?
You can use CTRL+SHIFT+A and look for Load Maven Changes or CTRL+SHIRT+O to do the same thing
I am trying to open this module in Intellij:
https://github.com/eugenp/tutorials/tree/master/javaxval
The steps followed by me:
Go to required directory javaxval/ in my local and
mvn clean install.
Open the pom.xml inside javaxval/ and open it as a project.
But Intellij is not syncing with the libraries mentioned in pom.xml as I can see in libraries section in Project Structure settings. Also, because of that, I can see lot of compilation errors.
Any idea what is the issue I am facing and how can I fix it?
This project imports and builds fine in IntelliJ IDEA 2019.2.2 version using the bundled Maven 3.6.1 for importing and JDK 1.8.
If it doesn't import/build for you, perform the diagnostics and check the logs as described in this answer. Make sure the parent pom file is present in the directory tree on your disk.
In Intellij IDEA 2017.2, I am trying to import an existing multi-module Maven project which builds fine outside the IDE via Maven. When the import is complete, I noticed that in one of the Maven submodules, a symbol is unresolved, lets call this submodule submodule-problem. The unresolved symbol is a class that is defined in another submodule, lets call that submodule-other. The thing is that in submodule-problem, other classes defined in other submodules at the level of submodule-other are found ok(those submodules are defined as dependencies in the pom file of submodule-problem). Furthermore, submodule-other isn't declared as a dependency in submodule-problem's pom file. But I should NOT have to do this because as I mentioned mvn clean install -Dmaven.test.skip=true works fine. So does mvn test-compile. I am using the latest Maven 3.5.0 and have instructed IDEA to use the same for the said imported project in the project's Maven settings. Note: I don't have permission to show the code or concerned POM files.
Things I've tried to resolve the issue so far are:
Invalidate caches and restart IDEA, many times
Re-import as Maven project, many times
Delete the .idea folder and all *.iml files from the said project and re-import as Maven project, a few times
Delete IDEA's system preferences folder and retry all previous steps again many times (this step was painful as I had to install all my plugins and configure IDE setting over again)
Imported the same project into Eclipse-Oxygen and saw that it doesn't have any issues with the importing of the project.
I have solved the problem. It turns out that it wasn't any problem with the IntelliJ IDEA IDE (at least I think not). In production, my top level project is a child project of another parent Maven project and so it's version in it's pom file references the parent's version using ${project.version}. Whereas in development it IS the parent with the lower level projects being it's own children. So in all pom.xml files, where ${project.version} was being used by my top level project to refer to the production parent and also in the children poms where they were referring to my top level project as their parent, I changed it to something like a literal like 1.0.0-SNAPSHOT and all problems went away, I didn't even have to re-import the project into the IDE.
Now, as I mentioned in the original post, even without having to do this, Maven had no problem building the project. I'd love to know why if anyone knows. Perhaps the IDE needs me to do this because it is trying to enforce some best practice? I was led to the solution by watching idea.log where it complained about some POMs being invalid and indeed in those pom files the version tag had a red squiggly underline.
I cloned one of the open source git repositories and was trying to import it as maven project in eclipse. After I imported everything as a maven project, whole package is getting messed up. See the below error:
How can I fix this issue so that I can build it on my local box? I cloned the same git repository locally on my desktop.
I am using eclipse version:
Eclipse IDE for Java Developers
Version: Luna Service Release 1a (4.4.1)
Build id: 20150109-0600
Steps I have tried already:
I have already tried maven->update project.
I have also tried removing and adding it again.
I tried mvn clean install both on command line and eclipse, they are successful as well.
Can anyone help me with this? If needed, you can also clone it and try importing it to see whether it works for you or not.
The root of your problem is that the build section of the pom.xml for that project specifies:
<sourceDirectory>./src</sourceDirectory>
Eclipse uses the sourceDirectory tag to tell it where the root of the main sources are. If you change that to ./src/main/java, then right-click on the project > Maven > Update Project... and click Ok (I had to do this twice) it will fix the Eclipse classpath so Eclipse can build the project. You can then revert the pom back to the head revision and so long as you don't run Update Project again it should continue to build.
I'm unclear on why that project specifies a non-standard source directory but uses the standard Maven layout, but this should at least get you into a working state within Eclipse.
I have used the m2e plugin in luna 4.4.1 for a while for handling dependencies and it worked fine. Normally, I create new Java projects then convert them into a Maven project.
I decided I wanted to start using the standard Maven directory layout, so for my most recent project I created it as a Maven project and then added the Eclipse Java facet so that Eclipse would treat it like a Java project.
This has broken Maven, so that it is no longer making it's dependencies available to new projects. Normally, Eclipse adds a "Maven Managed Dependencies" library to a project with Maven dependencies; new projects no longer do this and the dependencies are never added to the project classpath. Projects that had been working before still add and remove them normally.
I have narrowed the problem down to a .classpath error; for some reason m2e has stopped modifying the project classpath to make it's dependencies available. I can work around it by manually copying and pasting the entries from a working project but I would like to find a way to "re-automate" it correctly.
I have sidestepped the issue by finally buckling down to learn Gradle.