添加jar包到本地Maven仓库

首先测试maven环境是否正常

在cmd命令行中输入mvn -v 进行测试。

添加jar包到本地Maven仓库

 

下载需要的jar包

这里推荐几个maven仓库:

http://maven.aliyun.com/mvn/view

http://search.maven.org/

http://mvnrepository.com/

命令详解:

安装指定文件到本地仓库命令:mvn install:install-file
 -DgroupId=<groupId>       : 设置项目代码的包名(一般用组织名)
 -DartifactId=<artifactId> : 设置项目名或模块名 
 -Dversion=1.0.0           : 版本号
 -Dpackaging=jar           : 什么类型的文件(jar包)
 -Dfile=<myfile.jar>       : 指定jar文件路径与文件名(同目录只需文件名)

开始安装

例如现在下载了一个log4j-1.2.8.jar包并保存在了C盘目录下。

在cmd命令行下执行:
 

mvn install:install-file -Dfile=c:/log4j-1.2.8.jar -DgroupId=apache-log4j -DartifactId=log4j -Dversion=1.2.8 -Dpackaging=jar

 添加jar包到本地Maven仓库

最终提示BUILD SUCCESS即表示成功。

接下来就可以在pom文件添加依赖了。

<dependency>
    <groupId>apache-log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.8</version>
</dependency>

 

 

相关文章:

  • 2022-12-23
  • 2021-06-08
  • 2021-10-01
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
猜你喜欢
  • 2021-09-03
  • 2021-11-19
  • 2021-12-22
  • 2022-12-23
相关资源
相似解决方案