maven添加jar包



一、将jar添加到本地仓库的做法:

以下面pom.xml依赖的jar包为例:

实际项目中pom.xml依赖写法:

   <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>${pagehelper.version}</version>
   </dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>3.1.0.RELEASE</version>
</dependency>

Maven 安装 JAR 包的命令是:

  1. mvn install:install-file   
  2. -Dfile=jar包的位置   
  3. -DgroupId=上面的groupId   
  4. -DartifactId=上面的artifactId   
  5. -Dversion=上面的version   
  6. -Dpackaging=jar  
mvn install:install-file 
-Dfile=jar包的位置 
-DgroupId=上面的groupId 
-DartifactId=上面的artifactId 
-Dversion=上面的version 
-Dpackaging=jar

例如我的这个spring-context-support-3.1.0.RELEASE.jar 文件放在了"D:\mvn\"中

则命令为:

mvn install:install-file 

-Dfile=D:\mvn\spring-context-support-3.1.0.RELEASE.jar 

-DgroupId=com.github.pagehelper

-DartifactId=pagehelper 

-Dversion=3.4.2.fix

-Dpackaging=jar

注意:任何路径和名称不要有中文和空格,以防出现莫名其妙的错误。

安装之后的jar包位于C:\Users\admin\.m2\repository\com\github\pagehelper\pagehelper\3.4.2-fix

二、不讲jar包添加到本地仓库也可在maven工程中使用外部jar包的做法:

假设将包htmlparser.jar放入了项目下的lib目录中 :
-> E:\培训视频\淘淘商城项目(有源码)(更多视频教程关注微信公众号【菜鸟要飞】)\02.第二天(框架整合,后台系统搭建)(更多视频教程关注微信公众号【菜鸟要飞】)\01.参考资料\01.参考资料\pagehelper-fix\pagehelper\target\pagehelper-3.4.2-fix.jar
 
则pom.xml文件中依赖可以如下:
[html] view plain copy  
 在父工程(parent)中添加这样的依赖就行了,
   <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>${pagehelper.version}</version>
    <scope>system</scope>
    <systemPath>E:\培训视频\淘淘商城项目(有源码)(更多视频教程关注微信公众号【菜鸟要飞】)\02.第二天(框架整合,后台系统搭建)(更多视频教程关注微信公众号【菜鸟要飞】)\01.参考资料\01.参考资料\pagehelper-fix\pagehelper\target\pagehelper-3.4.2-fix.jar</systemPath>
   </dependency>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值