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

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.

Related

Maven Build Scripts Found - IntelliJ - What are the build scripts, where are they cached?

So basically, as the title of the post states, I'm wondering what IntelliJ is referring to when it says that Maven build scripts were found? Are these scripts that Maven keeps cached or are they IntelliJ specific? If they are generated by Maven, where are they stored/ how can I view them if that is possible?
Thanks!
This notification is to inform you that you are working with IntelliJ IDEA project that is not linked to the external build system (Maven or Gradle).
When you open a project in IntelliJ IDEA that was not initially imported from Maven/Gradle and IDE detects pom.xml or build.gradle files in the project, it will display a notification so that you can properly import the project from the build script.
Build script in your specific case is a pom.xml file stored inside a project directory. It's recommended that you open Maven projects by importing the root pom.xml file.
When a project is not imported from the external build system, your source roots configuration may be incomplete and you may be missing the dependencies.

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

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.

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 .

Mule copies Maven dependencies into env.M2_REPO folder

I am using Anypoint Studio 6.2 with Mule 3.8.1 runtime and Maven 3.3.9 and when I build my project, the Maven dependencies are written to a project folder called ${env.M2_REPO} instead of my usual Maven repository c:/users/my.name/.m2.
How can I change it back to c:/users/my.name/.m2 and stop this folder from being created?
It is causing errors to show in the Mule Problems tab saying "missing libraries" but when I move them from the ${env.M2_REPO} folder to c:/users/my.name/.m2 the problems go away.
The issue was that in the settings.xml file in the Maven application folder, the default repository was set to env.M2_REPO instead of the .m2 location. Changed it to .m2 and all working correctly.
right click on project--> Java Build Path-->Add Variable --> configure
variables--> Classpath variables--> new
-----------OR---------------
preferences-->Java--> Build path--> classpath variables
name: M2_REPO
path: location of repo
Update1:
right click on project, you will see something like this.
first time click on
populate maven repository
..
If your problem still didn't fixed then click on
Update project dependencies
.. This is how it fixed my problem few months back.

Gradle project dependency not working

Can some one please help me in below:
I am using RTC and checkout Gradle project, but at the end when I am checking the properties and looking for source folder for my build, I am getting nothing.
Also I am not send the repository specific Gradle jars. What i am doing wrong?
I tried including external jars but no luck as their are too many jars.
Error: project is not at all building.
right click on your project then configure and convert it to gradle project.
Refresh and you will see all dependencies.

Resources