In the process of using MAVEN, it is common to encounter some jar packages that are not in the central repository. If the company has a business, install the jar package on the. If there is no one, install the jar package to the local Maven repository. Today you'll get to the bottom of the 2 ways to install jar packages to your local maven repository.
One, install the jar package with the MAVEN commandpremise: In the Windows operating system configured MAVEN environment variables, how to configure please yourself Baidu, here is not introduced, canReferenceHttps://jingyan.baidu.com/article/cb5d61050b8ee7005d2fe04e.html
under the cmd command for Windows, refer to the following installation command to install the jar package. Note: This command cannot be wrapped, separated by a space in the middle.
安装指定文件到本地仓库命令:mvn install:install-file
-DgroupId=<groupId> : 设置项目代码的包名(一般用组织名)
-DartifactId=<artifactId> : 设置项目名或模块名
-Dversion=1.0.0 : 版本号
-Dpackaging=jar : 什么类型的文件(jar包)
-Dfile=<myfile.jar> : 指定jar文件路径与文件名(同目录只需文件名)
安装命令实例:
- mvn Install : Install - file - DgroupId = com . Baidu - DartifactId = Ueditor - Dversion = 1.0.0 -dpackaging=jar -dfile= Ueditor - 1.1 . 2.jar
after executing the command, you can see the success word, indicating that the installation was successful, can be found in the local warehouse. Ii. Installing the jar package with eclipseThere is also a prerequisite for using Eclipse installation, which is that the eclipse MAVEN needs to be configured first. But I do believe that the MAVEN settings of the eclipse, which is the only one of my friends, are sure to be fine, or maven.
Specific operation:
(1) File-->import-->maven-->instal or deploy an artifact to a Maven repository
(2) Fill in the relevant information, such as MAVEN coordinates, specific reference. Click Finish when you are finished.
(3) after the completion of the above steps, it is already done, you can go to the local warehouse to see the above installed things are not.
Comparison of the two schemesScenario One: The drawback is that it is cumbersome, for example to configure environment variables, and to write lengthy installation commands. However, if you configure the environment variables, it's easy. Copy the example of an installed command, and then install it directly. Scenario Two: Need Eclipse, personal recommendation this way, relatively simple.
Add jar package to local MAVEN repository