简体   繁体   中英

Eclipse maven plugin how to add jar?

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.

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM