欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

如何将jar包打入到本地maven库中

程序员文章站 2022-06-18 17:16:04
...

(1) 首先选中项目右击,export,然后选中源文件,填上保存路径即可得到jar包。

(2)为方便起见,可以先将jar包放入d盘根目录下

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\lenovo>mvn -v

Apache Maven 3.0.4 (r1232337; 2012-01-17 16:44:56+0800)
Maven home: C:\Program Files (x86)\Java\apache-maven-3.0.4\apache-maven-3.0.4\bi
n\..
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_79\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

C:\Users\lenovo>d:

(3)执行命令

D:>

mvn install:install-file -Dfile=D:\SocketServiceResource.jar -DgroupId=com.c
mbc.socketservice -DartifactId=com.cmbc.socketservice -Dversion=1.0.0.RELEASE -D
packaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-po
m ---
[INFO] Installing D:\SocketServiceResource.jar to d:\repository\com\cmbc\sockets
ervice\com.cmbc.socketservice\1.0.0.RELEASE\com.cmbc.socketservice-1.0.0.RELEASE
.jar
[INFO] Installing C:\Users\lenovo\AppData\Local\Temp\mvninstall51317731576048254
84.pom to d:\repository\com\cmbc\socketservice\com.cmbc.socketservice\1.0.0.RELE
ASE\com.cmbc.socketservice-1.0.0.RELEASE.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.970s
[INFO] Finished at: Mon Mar 27 18:57:54 CST 2017
[INFO] Final Memory: 5M/244M
[INFO] ------------------------------------------------------------------------
D:\>mvn install:install-file -Dfile=D:\SocketServiceResource.jar -DgroupId=com.cmbc.socketservice -DartifactId=com.cmbc.socketservice -Dversion=1.0.0.RELEASE -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-po
m ---
[INFO] Installing D:\SocketServiceResource.jar to d:\local_repository\com\cmbc\s
ocketservice\com.cmbc.socketservice\1.0.0.RELEASE\com.cmbc.socketservice-1.0.0.R
ELEASE.jar
[INFO] Installing C:\Users\lenovo\AppData\Local\Temp\mvninstall58792773539181329
45.pom to d:\local_repository\com\cmbc\socketservice\com.cmbc.socketservice\1.0.
0.RELEASE\com.cmbc.socketservice-1.0.0.RELEASE.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.689s
[INFO] Finished at: Mon Mar 27 19:07:35 CST 2017
[INFO] Final Memory: 6M/308M
[INFO] ------------------------------------------------------------------------
D:\>mvn install:install-file -Dfile=D:\SocketServiceResource.jar -DgroupId=com.c
mbc.socketservice -DartifactId=com.cmbc.socketservice -Dversion=1.0.0.RELEASE -D
packaging=jar

(4)然后在项目中的pom文件中引用即可

<dependency>
        <groupId>com.cmbc.socketservice</groupId>
        <artifactId>com.cmbc.socketservice</artifactId>
        <version>1.0.0.RELEASE</version>
  </dependency> 

(5) 然后点击项目右击 maven-install即可

相关标签: maven jar