Tutorial One:
For jar packages that are not on the official website, MAVEN imports the jar package to the local repository with the following command
Java code
- MVN Install:install-file
- -dgroupid= Package Name
- -dartifactid= Project Name
- -dversion= Version number
- -dpackaging=jar
- -dfile=jar file path
Take pinyin4j-2.5.0 as an example:
1. Place the Pinyin4j-2.5.0.jar file in the "D:\JAR_LIB" directory (any of the directories)
2. Execute the command:
MVN install:install-file-dfile=d:\jar_lib\pinyin4j-2.5.0.jar-dgroupid=net.sourceforge.pinyin4j-dartifactid= Pinyin4j-dversion=2.5.0-dpackaging=jar-dgeneratepom=true-dcreatechecksum=true
This makes it successful for Maven to import the Pinyin4j-2.5.0.jar package into the local repository.
3.pom.xml file configuration:
XML code
- <dependency>
- <groupId>net.sourceforge.pinyin4j</groupId>
- <artifactid>pinyin4j</artifactid>
- <version>2.5.0</version>
- </dependency>
Tutorial Two:
Sometimes, you project'll has dependency on a jar which are not in official maven repository , and maybe it is propriety jar file which would never be part of maven repository . In this case, you had to put it to your localrepository your the dependency.
There is a-install plug in to doing this job, which are something like:
Java code
- mvn install:install-file
- -dgroupid=<your_group_name>
- -dartifactid=<your_artifact_name>
- -dversion=<snapshot>
- -dfile=<path_to_your_jar_file>
- -dpackaging=jar
- -dgeneratepom=true
For example, your want to install the Danga ' s memcached client plugin, you can do:
This would add the Memcache jar into your local Maven2 repository under GroupId Com.danga and Artifactid memcached, You can then edit the your pom.xml adding this dependency.
However, the maven Eclipse can not recognize it since it always search from public repository
MAVEN imports the jar package to the local warehouse