Equivalent mvn eclipse:clean eclipse:eclipse m2e command - java

I have a Maven error like the following in Eclipse for a Maven project.:
Project 'project1' is missing required library: '.../.m2/repository/.../project2/0.37.0-SNAPSHOT/project2-0.37.0-SNAPSHOT.jar'
The project cannot be built until build path errors are resolved
The error is wrong, because in the parent pom.xml version 0.38.0-SNAPSHOT is defined, which also lies in the .m2 repository as project2-0.38.0-SNAPSHOT.jar
I tried: "Right click" -> "Maven" -> "Update Project...", but it does now solve the problem.
Then I tried: mvn eclipse:clean eclipse:eclipse, which solved the problem. But, then the problem is, that it converts the Eclipse Maven project to an Eclipse project. So I have to manually convert it back to an Eclipse Maven project. I also wonder because Apache Maven Eclipse Plugin is RETIRED.
Is there another solution to the above Problem?

Your error messages sais something about 0.37.0-SNAPSHOT but in your text you refere to 0.38.0-SNAPSHOT. Is it a mistake or maybe the version in your dependency is wrong?
First your are right not to mix mvn eclipse:eclipse and eclipse-m2e plug-in. Second the Maven->Update Project should fix any misconfiguration.
I would suggest to call mvn clean install in your console to verify that there are no real dependency problems. Eclipse sometimes does not update its index correctly.
Second if the error still appears try to restart your eclipse. I often saw that eclipse-m2e does cache some stra

Related

How to do Maven Clean and maven update project in Intellij idea

I am shifted from eclipse to intellij idea to work with my Spring boot project. there i found only maven clean option, but I am unable to find out how to do maven update. instead there it has maven build option, the build option created .class files. But i need to update only my dependencies.
To update the dependency it is enough to update its version in pom.xml and invoke Reload All Maven Projects action in Maven tool window. If dependency is not updated there is some problem.
step by step :
and your enter : mvn clean update
inside in IntelliJ, instead of Using maven update, we are using the maven install. so that it will install all the dependencies and update the project.

Eclipse not able to resolve Maven dependency

I have been working on a Java Maven project and my way of using it in Eclipse was to build it on command line and then import in Eclipse. The problem that I was facing is even though the project built successfully, eclipse was not able to resolve dependencies correctly.
This problem would usually go by cleaning, Maven updating and deleting and importing. However, this time it did not get resolved by following these steps. I tried a lot of already existing answers but nothing worked for me. However, I observed that the classpath is not getting created correctly:
I'm seeing that one of the dependency jars is marked as missing
I tried to create the Eclipse .classpath file using:
mvn eclipse:clean
mvn eclipse:eclipse
But mvn eclipse:eclipse fails with the following message:
Failed to execute goal on project consultation: Could not resolve
dependencies for project
company.compliance:consultation:jar:1.0-SNAPSHOT: Failure to find
company.compliance:commons:jar:1.0-SNAPSHOT in
http://maven.ia55.net/company was cached in the local repository,
resolution will not be reattempted until the update interval of
company-mvn-repository has elapsed or updates are forced -> [Help 1]
I read in some of the answers that this can also happen if m2e is not configured properly (it should be pointing to the commandline maven and not embedded maven). When I checked I saw that I don't even have m2e so in installed it. I don't know how to configure it to point to my Maven.
However, I doubt that this problem is because of the plugin not working otherwise I would not have been able to work in Eclipse peacefully till now.
So my other question is, isn't the success of mvn clean package enough to warrant that eclipse should not have any compilation errors regarding dependencies or does scope of dependency also plays a role and that I should work on getting the jar in the repo.
Is there any other possible issue that I am missing?
The issue got resolved. Earlier i was only importing the project that i wanted to work on. After importing all the projects in the directory which contained the pom, eclipse resolved the dependencies. Have no clue how this worked but it did.

Classes can't be found in Maven Dependencies

I suddenly encountered the following problem: it does not recognise certain class files from the dependencies.
Screenshot
Thinking it was because of my installation, I re-installed everything from Java to the Maven Plugin and tried to compile and run the SimpleExample from a clean project. Which gives the following result: Screenshot and the following exception: Screenshot
Your project is missing the dependency rinsim-core with groupId com.github.rinde.
Check with dependency:list if it is present. If not, add it.
If it is already there, try to compile the project outside eclipse. Install a command line maven, navigate to the directory, do mvn clean package and report any error you get as a comment under this answer.

Maven dependency not getting updated with LATEST version

I'm using intelij. I have multiple maven projects.
I deployed new version of maven Project_1, in the logs intelij showed version like this 1.0.0-20170331.023320-3.jar
Then in other Project_2 in pom file at I set the version of Project_1 as LATEST and run install. And in the logs intelij shows that 1.0.0-20170330-253 version was downloaded. It has different timestamp and when I'm checking the file in the external libraries, it doesn't contain my recent changes.
Please, advise, what I'm doing wrong?
You may want to "Reimport all maven projects" in IntelliJ which will redownload the dependencies
Right click on the Project -> select Maven -> Click Reimport
First Please use mvn command line like mvn compile to find the problem.
Set the version to 1.0.0-SNAPSHOT not Latest, if you set the version to snapshot, if you using mvn compile command, I will check the dependency for the latest one in the maven repo. If you are using Intellij try to reimport the maven project.

maven- not downloading new added dependency in pom.xml file

I need new third party jar for reading csv in maven based project. So, I did entry in pom.xml for same as below.
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.0</version>
</dependency>
But when I run mvn install or mvn package command, It does not download newly added dependency and just build project and generate war.
I am trying to get the issue! Please share solution if anybody face this earlier!
Regards
Try running a forced update:
mvn clean install -U
The -U (uppercase U) forces maven to look at all dependencies and try to update them.
If the dependency is defined in a <dependencies> block that is within a <dependencyManagement> block, adding it without the version number to a <dependencies> block that is outside <dependencyManagement> may fix the problem.
This is because the purpose of <dependencyManagement> block is to manage dependency versions, and not to install the dependencies. See this other article: Differences between dependencyManagement and dependencies in Maven
I resolved this issue by following steps:
1). Remove concerned jar from local /m2 folder.
2). Run mvn eclipse:eclipse command
3). And last run: mvn clean install
Now I am looking for concerned jar in my project class path!
If you are using IntelliJ Idea as your editor then simply follow 3 simple steps:
Right click on your project
Select Maven (last option probably)
Select "Reload project"
And that's it, IntelliJ Idea will download the dependencies and now you can proceed further.
Try:
Menu -> Project -> Clean -> Select the project
Right Click on the project -> Maven -> Maven clean
Right Click on the project -> Maven -> Maven install
Happened to me and it has fixed my problem. Hope it helps you.
I deleted .m2 folder and then from eclipse ran maven install then took maven update project. It resolved my issue and jar file got downloaded.
You can usually resolve these errors by updating Maven dependencies as follows:
Right-click on your top-level project (not on the pom.xml file) in the Project Explorer view.
From the menu, choose Maven > Update project
Make sure ForceUpdate of Snapshots/Releases is checked, and click OK.
You'll see a progress indicator in the lower-right-hand corner of the application window. When the update completes, you should be able to generate code normally, and the error markers should disappear.
In IntelliJ
Right-click on your root folder of the project in the Project Explorer view. From the menu, choose Maven > Reload project.
After that, your new dependencies will be downloaded. Then you should be able to generate code normally, and all the error markers will disappear.

Categories