Reprinted from : https://www.cnblogs.com/lixuwu/p/5855031.html

1 maven Local warehouse

maven In the local warehouse jar The directory is generally divided into three layers : In the picture 1 2 3 They are as follows :

1 groupId
2 artifactId
3 version
4 jar Package dependency

If you want to maven In the local warehouse jar Package added to project , Open it directly 4 xx.pom file , Will change jar Dependent replication of packages pom.xml In the file .

2 Will local jar Package added to local warehouse

2.1 add to jar To local warehouse

In principle, Maven We don't need to do that in our design , because pom.xml Depending on jar The package will be automatically downloaded from the central warehouse to the local warehouse .

But there are also special cases .

For example, I downloaded

lucene-queryparser-4.6.1.jar

How to add jar To the local warehouse ?
step :
1.cmd Command to enter the jar Package path

( Shortcut key :shift+ Right click   Select here to open the command line window )

ps:jar Packages can be in any folder Directory , Don't put it in the root of the partition , And don't create it yourself maven Related directories in .

There's no need to create a related directory ,mvn install After that, the related jar Put the bags in the local warehouse .

2. Carry out orders :

mvn install:install-file -Dfile=lucene-queryparser-4.6.1.jar -DgroupId=org.apache.lucene -DartifactId=lucene-queryparser -Dversion=4.6.1 -Dpackaging=jar

among :-DgroupId and -DartifactId The purpose of this is to specify this jar Wrapped in repository Installation path for , It's just used to tell the project to find the name in this path jar package .

Generally used jar The bags are all there mven Downloaded from the warehouse , therefore groupId and artifactId Directly copy maven The setting in the warehouse is OK .

<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-queryparser -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>4.6.1</version>
</dependency>

such as :
mvn install:install-file -Dfile=hadoop-hdfs-2.2.0.jar -DgroupId=org.apache.hadoop -DartifactId=hadoop-hdfs -Dversion=2.2.0 -D -Dpackaging=jar
It means to put hadoop-hdfs-2.2.0.jar The installation to repository\org.apache.hadoop\hadoop-hdfs\2.2.0 Under the table of contents , After executing the order , If you need to use this in a project jar, It's in pom.xml Add the following configuration to :

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.2.0</version>
</dependency>

ps: After execution of the above order , In the jar In the directory where the package is located, a jar The name of the bag .pom The file of , There are descriptions in it jar Coordinate information of the package .
Tips : The file directory is just an identifier jar The location of , You can also directly put jar Package replacement , You can use the previous coordinates , Import the replacement... In the project jar package . It's easier to do that , But it's not advocated .

Be careful , In the order , Each parameter is preceded by a -D identification .

2.2 add to lib In the catalog jar Package to local warehouse

How the pom.xml In the project libs Under the jar Well , Instead of adding from the local repository ?

1、 The first thing to add is jar The package is copied to libs Under the folder

2、 And then in pom.xml Add the following code to :

<dependency> 
<groupId>htmlunit</groupId> 
<artifactId>htmlunit</artifactId> 
<version>2.21-OSGi</version> 
<scope>system</scope> 
<systemPath>${project.basedir}/libs/htmlunit-2.21-OSGi.jar</systemPath> 
</dependency>

Be careful libs This one in the folder jar The bag doesn't need Add to Build Path

( This method has not been tried )

Here is maven The address of the central warehouse :

http://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit/2.21

You can search here for what you want jar package , Then copy the dependency code to your project pom.xml in , Corresponding jar The package will be downloaded to your local maven Warehouse , To provide you with .

( turn ) How to be in maven Of pom.xml Add local to jar More articles about the package

  1. ( turn ) How to be in maven Of pom.xml Add local to jar package

    1 maven Local warehouse maven In the local warehouse jar The directory is generally divided into three layers : In the picture 1 2 3 They are as follows : 1 groupId 2 artifactId 3 version 4 jar Package dependency If you want to ...

  2. As long as the project is maven Built ,pom.xml Depending on jar Package all default to your computer local warehouse to find

    As long as the project is maven Built ,pom.xml Depending on jar Package all default to your computer local warehouse to find

  3. eclipse Based on maven Built web project pom.xml Specified in the jar Package cannot be published to tomcat in

    eclipse function maven web Project report error : Information : Starting Servlet Engine: Apache Tomcat/7.0.57 January 07, 2015 11:50:44 Afternoon or ...

  4. How to be in maven Add local to jar package

    mvn install:install-file -DgroupId=mytest-DartifactId=test-Dversion=1.1 -Dpackaging=jar -Dfile=d:\te ...

  5. maven Of pom.xml Profile dependent jar package

    <!-- Declare variables --> <properties> <project.build.sourceEncoding>UTF-8</project.build.sou ...

  6. maven project pom.xml Load local jar, Customize jar

    take jar Put it in resource Below directory : pom Add the configuration <!-- load IK Customize rely on --> <dependency> <groupId>com.ik.up< ...

  7. All of a sudden pom.xml It is quoted in jar Package error .

    In your local warehouse , use window Search contains .lastupdated The file of , Delete all ! Then go to the project maven ------update project

  8. towards maven Add local to jar package

    <dependency> <groupId>org.csource</groupId> <artifactId>fastdfs-client-java& ...

  9. pom.xml Add remote warehouse to

    maven Of pom.xml Add remote warehouse to <repositories> <repository> <id>mvnrepository</id> < ...

Random recommendation

  1. Share an easy to understand js De reordering method

    <script> var arr=[1,8,6,4,88,22,99,4,6,86,5,58,89,5]; // First use sort() Function de duplication var a=arr.sort(function ...

  2. ueditor In the use of requirejs when , newspaper ZeroClipboard undefined error

    I found it on the Internet http://blog.csdn.net/xundh/article/details/44536665        Such an article , The reason is very clear It's because there are requirejs when , ...

  3. Cloud server ECS Linux Modify encoding format

    https://help.aliyun.com/knowledge_detail/41424.html?spm=5176.7841174.2.19.Le8kvy Usually , Cloud server ECS Linu ...

  4. UVA 11806 Cheerleaders ( Principle of tolerance and exclusion )

    The question One n*m In the area , discharge k I'm a cheerleader , first line , The last line , First column , The last column must be placed , How many ways are there . Ideas set up A1 In the first line ,A2 In the last line ,A3 In the first column ,A4 The last column is placed in , Requirements |A ...

  5. ftp Upload java Code

    < Welcome to reprint http://www.cnblogs.com/shizhongtao/p/3345826.html> Upload code to write a simple small example . First of all, join jar package .commons-net-1. ...

  6. 【Android &amp; iOS】 Application upgrade implementation

    In mobile applications , There will be a function is to upgrade the application version , How to realize this function ? The basic idea is : Compare the current application version with the latest version number , If version number is inconsistent , You can prompt users to upgrade . Android in , It can be done in the following ways ...

  7. Ubuntu install Microsoft Windows Fonts Microsoft font library

    ttf-mscorefonts-installer The package is Microsoft's font package , You can find the installation directly in the software center , It can also be installed by command sudo apt-get install ttf-mscorefonts-ins ...

  8. Go The beginning of learning

    On a dark and windy night , Coincidence and Go It's just language , By her simplicity . flexible . Efficiency attracts , Let me have the impulse to study deeply , Now let's start my growth path .

  9. Android Error:Execution failed for task &#39;:app:compileDebugJavaWithJavac&#39; Solution

    Use today Android Studio This error occurred when building the project compileDebugJavaWithJavac There are many reasons for the problem found through the search, which need to be checked in combination with specific projects adopt Andro ...

  10. sqlalchemy Dynamic combination of query statements .

    if filter_type == 1: search = and_(GameRoom.status ==1,or_( and_(GameRoom.white_user_id == user_id, ...