0

I got my first Maven Project in Eclipse.

Now I want to add some jar file dependencies. Usually I have created a lib path and copied my .jar files inside of the lib path, which then are added to the class-path.

Now in Maven there is this dependency management and a static folder structure.

I am very new to Maven and would like to know how I can put my jar dependencies to the Maven Project.

I already found a "Add Dependency" on the pom.xml configurator panel. But there is only j-unit listed on it. So how do I proceed?

I have all jars I need already on my machine.

Praneeth
  • 1,260
  • 18
  • 37
Gobliins
  • 3,848
  • 16
  • 67
  • 122

2 Answers2

1

If you want add a jar search that jar as maven in Maven website. For example if i want to add an Mysql dependecy jar in maven i could refer here.

http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.6

Similarly you can search for such jars in maven where you get below details.

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

add this code in your Pom.xml file.

In order to add other jars search for respective jars in maven where you could find requested maven dependency.

srikanth r
  • 302
  • 3
  • 20
  • So it is not possible the other way round to move all jars in a folder and have the maven plugin generate this code? – Gobliins Oct 13 '15 at 12:45
  • One goal of Maven is to avoid to doing this. Do a list of your principal need (if you want to use Spring, find the good jar, maven will automatically add other needed jar in your project). In case of converting an existing project, you can take a look here : http://stackoverflow.com/questions/474725/generating-a-maven-pom-from-an-existing-project – GiBoX Oct 13 '15 at 14:43
0

You should find the jar on a public repository or you can add the libs on your personal reposioty on your machine

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
Bertotz
  • 38
  • 7
  • I already tried this but it didn't work at all. Can you provide an example where i can see the and the corresponding entry in the pom.xml? – Gobliins Oct 19 '15 at 07:43