Maven project builds but dependencies seem to be unavailable in IntelliJ IDEA - maven

I have a multi-level Maven project that builds fine on the command-line using mvn clean install and builds in IntelliJ IDEA (2019.3) by manually running the parent project's clean and install phase. The Problems view shows nothing wrong. When I open files that have certain external libraries, they show as being unable to be resolved:
I'm usually able to browse external libraries' contents in the project browser. I've noticed that these external libraries IntelliJ can't find are listed but not browsable.
Other people working on our project with the same code base and same IntelliJ version don't seem to have this problem. I've tried:
"Reimport all Maven projects"
File -> Invalidate Caches/Restart
Completely deleting my ~/.m2/repository
Completely deleting my $PROJECT_ROOT/.idea directory and reimporting
Recloning and reimporting the project from scratch
None of the above seem to work.

The root case for this problem was not identified and is still under investigation, but what can help is removing the IDE settings and starting with the defaults.

Related

Unresolved plugin: 'org.apache.maven.plugins:maven-compiler-plugin:3.8.0'

I tried to set up Maven projects under my IntelliJ IDE. However, when I try to update the pom.xml file, I am getting this error. I tried deleting the .m2 repository under Users, made the changes under Build Tools for Maven. Still, the issue doesn't seem to get resolved.
You can try
File -> Invalidate Caches -> Invalidate and Restart
so IntelliJ will try index again to the resources.

Importing to IntelliJ - Error package org.springframework.boot does not exist

Dear Stackoverflow Community, I have the following problem with my spring boot starter application. I imported the starter project as a new maven project into IntelliJ. But IntelliJ does not find the dependencies I specified in the pom.
Image of my Application Class:
If I try to run the project I get the following error message.
Image of the Error Message:
I already tried everything from re-installing IntelliJ to re-importing the project or redownloading the dependencies. I simply dont know why IntelliJ doesn´t find the dependencies.
My pom.xml looks as following
Image of my pom.xml:
The first time I tried to edit the pom.xml it said to me "this file does not belong to the project". Maybe this might be one reason.
Running the whole thing with 'mvn install' or 'mvn clean verify' works.
Try this and then build: mvn -U idea:idea
Had the same problem. I have tried everything: invalidating cache, deleting the whole .m2 folder, changing settings, reloding the project, nothing helped.
The solution for me was to delete the .iml files which are IntelliJ module files used for keeping module configuration. After reopening the project it worked.
The idea was not mine, I found the hint here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/203365204--package-does-not-exist-error-despite-autocomplete-being-aware-of-them
Sometimes your workspace could get corrupted.
In my case, I tried to Reload the project and it worked
in my case changed JDK version in Maven importer from JDK 11 to my local JDK version 1.8
Here is how my IntelliJ settings for spring boot application looks like
Click open -> browse your workspace -> and select POM.xml file
Check this in your intelliJ settings
Do this too [Settings --> Maven --> Importing]
I just had the same issue. My solution was to remove all dependencies from the pom, reload via maven -> Reload All Maven Projects. Run mvn compile. Add dependencies back to the pom, maven -> Reload All Maven Projects. Run mvn compile.
Now the Intellij build works.
You need to change Maven's JDK for importing option from Project JDK to the Path variable for Java on your machine.
You can get to this by going to Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing. Scroll down to the bottom and look for JDK for importing:. Select from the list the path variable for JAVA.
For Windows users, JAVA_HOME should be an option in the drop-down list.
Follow these steps, your problem should be solved. You just need to add Spring-framework-starter-web and Spring-framework-starter-tester from your pom.xml file.
Got to generate(ALT+Insert)
Add dependencies
Search "springframwork"
Add...
Here is the link
In my case, adding the project as maven project helped .

Maven pom.xml plugin not found. Screenshot attached

screenshot
All the dependencies and plugins in my project were resolved when I was using my old computer. Today I had to switch to the new one, reinstall all the programs and clone the project from git again. Right now I'm kinda baffled on how to solve this issue.
I've tried reimporting the project, invalidating caches and restarting IntelliJ Idea, performing mvn clean install -U, mvn clean install.
Still.
There are a couple of possibilities for this to happen:
Do you by chance have a custom settings.xml (mostly found in ~/.m2 folder) file pointing to another maven repository than maven central?
Versions of the plugins are unavailable or wrong?
Internet connectivity :-)
My guess is that your "old" computer had a custom settings.xml file which is not present on your new computer (yet)...

Maven Project in Eclipse `org.springframework cannot be resolved to a type` from target path

I've rolled onto a maven project that when I run mvn clean install from command line builds and runs fine. I had this project displaying in Eclipse without errors earlier in the week before I hosed my system. This makes me think I have a configuration wrong and hoping someone can give me a sanity check.
Inside of Eclipse, I'm seeing reported errors related to org.springframework cannot be resolved to a type in files in paths like <project_path>/target/<project>-<version>/WEB-INF/... What is catching my eye is that path of target which is a derived folder.
Maven Dependencies Showing:
Facets Enabled:
Project Explorer View:
From the above screenshots, you can see that the related jar files are pulled properly from the maven dependencies. Any ideas on what I have misconfigured and why I'm seeing the errors from the target path?
The build and WebContent folders indicate that you haven't properly imported Maven project into the Eclipse, hence errors.
One of the way to fix this:
Delete project from the Eclipse.
Go to project folder and delete all not needed folders. (Leave src).
Go to Eclipse click File -> Import..., select Existing Maven Projects, select your project folder, Finish.

Intellij maven imports have broken classpath

I'm using Intellij 13, I've been using Maven quite happily for awhile now to manage the JAR dependencies.
But the last few I've imported are causing a broken classpath issue, and they're not being installed to the repository.
I though it might be just the JSONPath library, but when I tried to install Selenium drivers it also happened with those libs. I checked the local repository and the directories exist, but the JARs haven't downloaded.
This only started happening recently, and a lot of other dependencies have been installed fine (but not since this issue started happening). I'm really not sure what might have caused it.
Does anyone know how to troubleshoot this? Or why the JARs aren't installing? And can I just trigger an update somehow from Intellij to try to reinstall them?
Quick Edit Here:
I tried installing the modules using Intellij's "add library" feature. It installed them fine, whereas before I was just updating them directly in the pom.xml and it was downloading them.
The library feature seems a little better because it automatically adds them to my output artefacts anyway, but it would be nice if it also updated the pom so I can use it outside of the intellij environment.
So I'm not sure why updating the pom.xml isn't working any more...
I've had this issue in IntelliJ IDEA 2017 Ultimate.
After changing dependency versions, the IDE was unable to fix the path on its own. I went to my ~/.m2 directory and deleted all of the dependencies for the problem jar and then executed the "ReImport All Maven Projects" action. When it was complete, the dependency issue was resolved.
I had this problem with the Community version of IntelliJ Community edition. I was able to solve the problem using this process:
Click "Help" menu
Click "Find Action" and type "Maven Settings."
Click "Maven Settings."
Click the arrow next to "Maven" on the left hand side, to see the submenu
Click "Importing"
Check "Import Maven Projects automatically" and click "OK."
This should pull in all of the Maven dependencies from the pom.xml file, without you needing to manually add the libraries.
I hope this helps.
I have encountered a problem like this.
I resolved it as follows:
Project Structure >> Modules >> your module has problem >> Dependencies
then double click the jar that have problem, go to "Configure Project Library",
and then click "+", i.e. I add dependency jar manually, otherwise, the dependency jar is red (i.e failed status) or have none.
It's not really an answer, but I moved some stuff around the POM's and it seems to be working. I've got a bad internet connection, and I found that it kept stalling trying to download some of the jar files, and Intellij didn't seem to time out when it did stall, I ended up having to restart it each time it stalled to get the JAR's to download.
But it's working okay now by just editing the pom files, which is more convenient for me than libraries.
In my case I was having this exact problem because I was trying to import a local jar-with-dependencies without classifier. To solve this I just needed to add <classifier>jar-with-dependencies</classifier> to the maven dependency, e.g.:
<dependency>
<groupId>com.my.group</groupId>
<artifactId>myartifact</artifactId>
<version>1.0</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
Hope this helps someone.
There can be different root causes of this issue. For me problem was that I had a maven settings file with a different name. Problem resolved after I went to intellij maven settings and updated the maven settings file path and then after maven refreshed my projects.
I solved the probelm by deleting it in module dependencies, and then importing it again.

Resources