In Eclipse Neon, I did an 'import existing maven project' from a local folder, whose content was copied from another machine. The project is not reading the dependencies on the POM file, and one example is the log4j dependency. A workaround is to add the log4j-1.2.17.jar manually to the project as an external jar, but this is wrong. Does anyone have tips on how to troubleshoot? I am fairly inexperienced with maven so I m not sure if there are additional settings or configuration that I have do when importing an existing project into eclipse.
You can make sure if your project dependencies are being pulled correctly or not by executing
mvn clean install
from within the project directory on the command line. This would download the required dependencies of the project as well.
The most common cause I have seen for this issue occurs whenever Maven encountered an error while downloading an artifact from a repository. In this case, Maven marks the download as failed and won't retry until some time elapses (I do not remember how long).
The easiest way to test this is to delete the .m2/repository folder in your home directory and let Maven download the artifacts again. If you have Maven installed you just execute "mvn install" from a console. Otherwise, you can try:
Right click the project in Eclipse
Select "Maven > Update Project"
Check "Force Update of Snapshots/Releases"
Click "OK"
Related
I have a problem with Eclipse: whenever I click Gradle > Refresh Gradle Project to refresh my Gradle dependencies, Eclipse deletes all of the external JARs in my build path. This happens with every Gradle project, and reinstalling Eclipse doesn't fix the problem.
The "Refresh Gradle Project" option:
Before and after refreshing:
Any idea how to fix this? Thanks in advance.
Yes, that is the expected behavior: Refresh Gradle Project resets the dependencies to the ones specified in the build.gradle file. So it overwrites your manually made changes in the Java Build Path.
In a Gradle project, instead of changing the Java Build Path settings directly, add all dependencies via the build.gradle file.
I can not post comment yet.
Did you check the gradle setting for repo locations ?
Eclipse may not able to get the jars from the repo.
and also did you try
gradle eclipse
to refresh the eclipse dependencies from command line, and refresh the project in eclipse.
I am having trouble deleting an external dependency from my build path. I have searched this site and the web but have not found a good answer.
I use gradle 4.9 and eclipse 4.7.3a to manage my automated tests. I have placed external jars in a folder named artifact in a git project's root directory.
My build.gradle file contains this line in the dependencies section:
compile fileTree(dir: "./artifact", include: '*.jar')
Well and good, it all works. However, when I try to delete a dependency using
Build Path > Configure Build Path... > Libraries > Project and External Dependencies
all the buttons, including Remove, are grayed out.
I can delete the file from the artifact directory and issue
gradle cleanEclipse
from the command line but when I open Eclipse and try to open the project (under Project Explorer) I get 'Open Project' has encountered a problem. The project description file (.project) for 'project name' is missing.
After replacing the old jar with the new version (different file name of course), I tried running
gradle
which is supposed to recreate configuration files deleted by cleanEclipse. No joy. Next, I tried running
gradle build
But after restarting eclipse, still a failure. The only thing that worked was to delete the project from eclipse and then to re-import it.
Is there an easier way?
Thank you.
Well, I found an answer.
After deleting and copying in the new jar file into the artifact directory, in eclipse, I selected Project > Clean ...
Then I right-clicked on the project and selected Gradle > Refresh Gradle project
I guess writing the question got me thinking about how eclipse handles .project files. Maybe this will help the next person.
I am working on a Maven project and I am using eclipse as an editor. I clone a project from GIT and then create a git repository in eclipse , import it and then create a maven project. After i finished the project of setup i got a lot of errors and this is due to pom.xml file and I am missing about 300 artifacts.I know want to know how can i find and add those artifacts in my project. I have seen different answers for that and one of the answers is to upload maven project. I did it but still not working , I am still missing the artifacts.
I really need some help here since i want to start working on this project as soon as possible.
Maven pulls all the dependencies either from maven repository or from local repository automatically (typically C:/Users/user1/.m2 on windows). if there are lot of dependencies, eclipse takes a while to download them all.
check if you see building workspace at the right bottom corner of eclipse. you can press Alt+F5 to refresh the project and then try command mvn clean install from your root folder (where your pom.xml is placed)
Sometimes, jars are not available on maven repository such as sqljdbc. in that case you will have to manually install them to your local repo using below command if you have the .jar file
mvn install:install-file -Dfile=<path-to-file>/stax-1.0.jar
-DgroupId=stax -DartifactId=stax -Dversion=1.0 -Dpackaging=jar
or a quick and dirty approach would be copy the .m2/repository folder from previous machine if project was working good on that machine.
I am learning building a Java project in Eclipse using Maven. I created a Java project HelloWorld from
“maven-archetype-quickstart” template in a folder D:/maven_projects. Then to convert the Maven project to support Eclipse IDE, I navigated into the project folder and issued the commands:
mvn eclipse:eclipse and mvn package .
Then I imported the project in Eclipse and did the necessary Eclipse configurations like setting the Maven local repository in Eclipse classpath. Now the project in D:/EclipseWorkspace folder. I ran the project successfully in Eclipse printing "helloworld".
Now if I want to go on develop the project and for that reason want to add new dependencies in pom.xml in Eclipse, then the new jars are not added in classpath when I run the project.
So my question is after importing a Maven project into Eclipse how can I add more and more dependencies in pom.xml, then build and run the project? What is the recommended and efficient way to do this?
I would recommend you don't use the m2eclipse command line tools (i.e. mvn eclipse:eclipse) and instead use the built-in Maven support, known as m2e.
Delete your project from Eclipse, then run mvn eclipse:clean on your project to remove the m2eclipse project data. Finally, with a modern version of Eclipse, just do "Import > Maven > Existing project into workspace..." and select your pom.xml.
M2e will automatically manage your dependencies and download them as required. It also supports Maven builds through a new "Run as Maven build..." interface. It's rather nifty.
1.Update project
Right Click on your project maven > update project
2.Build project
Right Click on your project again. run as > Maven build
If you have not created a “Run configuration” yet, it will open a new configuration with some auto filled values.
You can change the name. "Base directory" will be a auto filled value for you. Keep it as it is. Give maven command to ”Goals” fields.
i.e, “clean install” for building purpose
Click apply
Click run.
3.Run project on tomcat
Right Click on your project again. run as > Run-Configuration.
It will open Run-Configuration window for you.
Right Click on “Maven Build” from the right side column and Select “New”.
It will open a blank configuration for you.
Change the name as you want. For the base directory field you can choose values using 3 buttons(workspace,FileSystem,Variables). You can also copy and paste the auto generated value from previously created Run-configuration. Give the Goals as “tomcat:run”. Click apply. Click run.
If you want to get more clear idea with snapshots use the following link.
Build and Run Maven project in Eclipse
(I hope this answer will help someone come after the topic of the question)
Dependencies can be updated by using "Maven --> Update Project.." in Eclipse using m2e plugin, after pom.xml file modification.
Just install the m2e plugin for Eclipse. Then a new command in Eclipse's Import statement will be added called "Import existing maven projects".
answer 1
Right click on your project in eclipse
go to maven -> Update Project
answer 2
simply press Alt+F5
after updating your pom.xml. This will build your project again and download all jar files
Right Click on your project
Go to Maven>Update Project
Check the Force Update of Snapshots/Releases Checkbox
Click Ok
That's all. You can see progression of build in left below corner.
When you add dependency in pom.xml , do a maven clean , and then maven build , it will add the jars into you project.
You can search dependency artifacts at http://mvnrepository.com/
And if it doesn't add jars it should give you errors which will mean that it is not able to fetch the jar, that could be due to broken repository or connection problems.
Well sometimes if it is one or two jars, better download them and add to build path , but with a lot of dependencies use maven.
If you are getting this error :in cucumber Exception
Cucumber Exception: java.lang.ClassNotFoundException:
cucumber.io.ResourceLoader :
then add following jar file to your pom.xml
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.8</version>
</dependency>
Run the maven build once and should be gone
I imported a Maven project into Eclipse. I was able to deploy it from the command line. In Eclipse it is full of red Xs. I have cleaned the project, updated the configuration and I ran the following command:
mvn -Declipse.workspace=<pathtoworksapce> eclipse:add-maven-repo
and I still have the same problem. The project is dependent on another project.
What I ended up doing was removing all of the projects in Eclipse, but not deleting the source files. Then instead of directly importing the code as Maven->Check out as Maven Projects with SCM, I selected Existing Maven Project and imported the code from my local machine. This got rid of the errors, but when I would right click on code and select "Open Declaration", I would get Error: Could not open the editor: The file does not exist" So I removed all projects again and this time I deleted all the ".project" files and repeated the import Existing Maven Project. So now there are no red Xs (dependency problems) and the lookup functionality within the code works.
Go to your master project and type the following :
mvn install
mvn eclipse:eclipse
After that, import your project. You can also install m2eclipse for better support. If you use gwt or any other framework which has a custom maven execution, you should also install plugins for those in Eclipse.