How to add Maven dependency in Eclipse?

I do not know how to use Maven at all. I have been developing for a couple of years with Eclipse and should not know about it yet. However, now I am looking at some documents that suggest doing the following:

"To include it in your project, just add this maven dependency to your assembly."

<repository> <id>jboss</id> <url>http://repository.jboss.org/maven2</url> </repository> ... <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jackson-provider</artifactId> <version>1.1.GA</version> </dependency> 

How to do this with my Eclipse project?

Please assume that I do not know anything about Maven. I just realized that it can be installed on my computer by typing mvn at the command line, but it depends on my knowledge. I would be happy to continue to know nothing about Maven if there is an equivalent, non-Maven way to follow these instructions with Eclipse.

+68
java eclipse maven dependency-management
Feb 06 2018-12-18T00:
source share
5 answers
  • In the top menu bar, open Window β†’ Show View β†’ Other
  • In the Show Window window, open Maven -> Maven Repositories

    Show View - Maven Repositories

  • In the window that appears, right-click Global Repositories and select Go To

  • Right-click on the central one ( http://repo.maven.apache.org/maven2 ) and select " Rebuild Index "

    • Please note that it will take some time to complete the download.
  • Once indexing is complete, right-click the project β†’ Maven β†’ Add Dependency and start typing in the name of the project you want to import (for example, "sleep mode").

    • Search results will be automatically populated in the "Search Results" box below.
+131
Oct 14 '14 at 0:23
source share

In fact, when you open pom.xml, you should see 5 tabs below. Click pom.xml and you can enter any dependencies you want.

enter image description here

+10
Aug 14 '15 at 0:51
source share

For proper use, you need the Maven plugin for Eclipse. The m2e plugin is built into the latest version of Eclipse and does the decent, if not perfect, task of integrating Maven into the IDE. You will want to create your project as a "Maven project". In addition, you can import an existing Maven POM into the workspace to automatically create projects. When you have a Maven project in the IDE, just open the POM and add your dependency to it.

Now, if you do not have the Maven plugin for Eclipse, you will need to get jar (s) for the dependency in question and manually add them as classpath links to your project. This can be frustrating because you will need not only the top-level JAR, but all its dependencies.

Basically, I recommend that you get a decent Maven plugin for Eclipse and let it handle dependency management for you.

+7
Feb 06 '12 at 18:11
source share

Open the pom.xml file.

under the project tag add <dependencies> as another tag and google for Maven dependencies. I used this one to search.

So, after getting the dependency, create another dependency tag inside the <dependencies> .

So, in the end it will look something like this.

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>doc-examples</groupId> <artifactId>lambda-java-example</artifactId> <version>0.0.1-SNAPSHOT</version> <name>lambda-java-example</name> <dependencies> <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-lambda-java-core --> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-lambda-java-core</artifactId> <version>1.0.0</version> </dependency> </dependencies> </project> 

Hope this helps.

+1
Oct 17 '16 at 21:14
source share

I ran into a similar problem and fixed it by copying the missing Jar files to the .M2 path,

For example: if you see an error message like Missing artifact tws:axis-client:jar:8.7 , then you need to download the β€œaxis-client-8.7.jar” file and paste it in the location below to solve the problem.

C: \ Users \ UsernameXXX.m2 \ repository \ tws \ axis-client \ 8.7 (Insert axis-client-8.7.jar).

finally, right-click project-> Maven-> Update Project ... This is it.

happy coding.

0
Jun 22 '17 at 20:09 on
source share



All Articles