Maven Dependencies are not installing in eclipse - java

I am using the maven embedded eclipse.
Tried :
Deleting the whole m2 repository.
Maven->Update Project.
Run as -> Maven Build
User settings file does not exist(Please don't tell me it has to something with this file)
settings.Xml file
This file is only required if you are using a proxy and i am not
I have every dependency present in pom.xml file of my project but still eclipse is not able to import all these dependencies in the project
I have attached the photo below. Please help me to resolve my issue
mvn dependency:tree
Maven Dependencies
POM.xml file
List of dependency present in pom file of my project
None of the methods mentioned above worked so please help me to solve this issue.
Is there anything related to maven or eclipse version ?

When you execute mvn dependency:tree result shows an error related to "i cannot obtain some jar", it may be due to private reporitory.
If you are working with private repository, make sure you configure access in $HOME/.m2/settings.xml
On another hand I see you are working with snapshots. If you are trying to bind projects you have in your local host machine, ensure you are executing mvn install (or better mvn source:jar install) sucessfully and your system's maven is pointing the same .m2 path that refers Eclipse maven plugin

It seems using the Spring framework Maven repository via HTTP instead of HTTPS causing this issue.
In your pom.xml file replace http://maven.springframework.org with https://maven.springframework.org.

Related

Maven install fails after maven clean in eclipse

I have a maven project in Eclipse and I added some local jar files to the buildpath. If I do not add any dependency to the pom.xml file I am able to execute maven install. Then, if I add those dependencies to the pom the command maven install continues working as well. Now in this situation if I run maven clean then maven install fails. Why?
I also tried to run Maven -> Update Project but the result is the same. What is the problem?
If you are using non maven dependencies then it will fail to build eg from CLI and in your case in Elipse after cleaning the project as well. In order to make it work you have to installl tha JAR you are using as Maven artifact and the ninclude it in POM dependencies like every other library.
Here you have info on how to install 3rd party JARs to local repo
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
I got the same problem and resolved by adding the 3rd party in the pom.xml manually

POM file Uploaded by Artifactory Jenkins plugin won't resolve in Maven builds

I am building a jar in Jenkins and uploading it to an Artifactory repository. I've verified the jar, the pom, and the hash files are present in the repository. When I try to build a project on my machine that has a dependency on the jar, it downloads the jar correctly but then I get a POM file is missing message and the maven build fails. I don't see any rhyme or reason why this should fail, I've done an Artifactory trace on the jar and the pom in Chrome and Firefox and the response says that it found the files. So I don't understand what could bve causing the issue? We were running Artifactory 5.2.1 and upgraded over the weekend to 5.5.1, but it hasn't changed anything. What should I be looking at?
Thanks.
EDIT: This question is about to be moot. Discussions are in progress about setting up a generic maven repository and avoiding the use of Artifactory altogether, since it won't do what is needed.
First, make sure your groupId and artifactId are correct. I've lost a lot of time thinking it's a maven problem when it's really just that I reversed a couple letters in a long groupId.
Next, have you tried 'forcing' maven to bypass its local cache? Try running mvn -U <your tasks>
If that doesn't work, try deleting the ~/.m2/repository/path/to/the/artifact/with/the/missing/pom and use mvn -U again
OK, problem solved. Turned out to be a Maven problem, not an Artifactory problem. Our maven settings contain a proxy setting so we can pull down jar from Maven Central - problem was, our company url was incorrectly configured in the nonProxyHosts tag, was set to domain.org, instead of *.domain.org, so it was trying to retrieve the maven artifact through the proxy instead of going directly to the Artifactory server. My apologies to the Artifactory devs for blaming the problem on Artifactory.

Showing jars in maven dependencies section without doing mvn install in cmd

I have added dependencies in pom.xml and immediately the corresponding jars started to show up in maven dependencies section of dynamic web project.
I just want to know that I have not done mvn install in cmd so how did they get saved in maven repository.
Another query I have, is that since jars are availble in maven dependencies folder of dynamic wep project, so my project runs successfully or not as depndencies are already satisfied without doing mvn install.
When you list a <dependency> in your project's POM, M2Eclipse (Eclipse's plugin in this case) will trigger Maven to resolve that declared dependency...meaning Maven will check your local repo first for that dependency, and if it's not found there it will pull it down from the next highest repo you have configured (possibly an agency-level repo, or Maven's default public repo on the web).
No mvn install is required, as the purpose of that would be to install your current project's packaged artifact into your local repo, rather than install any dependency.
Hope this helps to clarify why an install is not used to copy dependencies into your local repo.

Maven repository location is not updated in eclipse

I have a Maven project. I have converted it to eclipse project using the command.
mvn eclipse:eclipse
I imported this project to eclipse. I am getting missing library error.
I have updated the maven repository details in Maven setting of eclipse.
My current maven repository is E:\myfolder\repository
I have edited this my settings.xml too.
<localRepository>E:\myfolder\repository</localRepository>
I have added a class-path variable MAVEN_REPO.
MAVEN_REPO = E:\myfolder\repository
The actual address of the jar in repository is M2_REPO/javax/ccpp/ccpp/1.0/ccpp-1.0.jar.
But the eclipse is not able to locate the jar in the repository.
It is taking default repository address.
Still I am getting missing library error and it is pointing to default maven repository address rather than my new repository address.
Project 'Testproj' is missing required library: '\\user dir\.m2\repository\antlr\antlr\2.7.6\antlr-2.7.6.jar'
Can some one tell how to overcome this error.
Thanks in Advance.
In eclipse, go to Preferences > Maven > Installations
Make sure that the Global Settings file is pointing to the right config and it is pointing to the right local repository.
This is what worked for me:
In Eclipse,
Windows->Preferences->Maven->User Settings
Even if the settings.xml was updated as expected it was still pointing to default directory. So i did 'Restore Defaults' then 'Apply'
And then i again changed the Global Settings and User Settings to point to correct settings.xml. Do Reindex for local repository. Click OK and bang!
Projects compiled perfectly!
Are you sure you did all the configurations and only then executed mvn eclipse:eclipse? Also is this mvn pointing to the same maven installation which you have configured? Before open the project in eclipse just check the generated .classpath file and see if it points to wrong location repo.
Although I would suggest this -
Eclipse has excellent maven plugin. You do not need to do mvn eclipse:eclipse.
Simply import project in eclipse as maven project. Before import ensure the maven plugin is configured to use the same settings.xml which you have configured for command line maven.

JAR in project-specific local Maven repo, how to see library in Eclipse project?

I've been trying to add a custom .jar (ftp://ftp.ncbi.nlm.nih.gov/pub/eutils/soap/v2.0/java/axis2_1.5.2_jdk_6.0.12/eutils_axis2.jar) to a project that doesn't have a central corporate maven repository and that instead will have the custom JARs checked into SCM in the project directory tree. I was following this post to make it happen: Maven: add a dependency to a jar by relative path (awesome post btw).
What I did was:
Add local repository to pom.xml
install the file into the local repository
Add dependency to pom.xml
Based on what I see in m2eclipse, the library has been successfully recognized by Maven and added to the dependency list (or it'd be called ? : ? or something similar)
The problem is that Eclipse still doesn't see the referenced lib, so this still fails:
import gov.nih.nlm.ncbi.www.soap.eutils.*;
Pardon my maven newbiness, but what are changes / next steps I need to make to get to:
Have Eclipse see the library so that autocomplete works (and the import can be resolved)
Be able to compile the project
Be able to execute the jar produced by mvn package?
Thanks!
If you see the JAR under "Maven Dependencies" in your project, Eclipse should be able to see and use it. If it's not there, then m2eclipse wasn't able to resolve the dependency properly.
If it is missing, m2eclipse was unable to download the dependency from your local repository for some reason. Check the Maven 2 Console for errors and the Problem View.
Lastly, the JAR itself might be corrupt. Maven doesn't check for that, it simply adds the file to the classpath. If Eclipse can't open the JAR, you can also get the errors you mentioned.

Categories

Resources