java 导入本地的JAR包到maven

来源:互联网 发布:新星号货轮事件知乎 编辑:程序博客网 时间:2024/06/03 23:57

首先要在maven项目所需的包引入到POM.XML上。如所需的包名称是json_simple-1.1.jar

则可以写

[java] view plain copy
  1. <dependency>   
  2.         <groupId>json_simple</groupId>   
  3.         <artifactId>json_simple</artifactId>   
  4.         <version>1.1</version>   
  5. </dependency>  
其实使用CMD命令行把所需要的包导入到本地MAVEN仓库中。

命令是:mvn install:-install-file -Dfile=包的所在路径 -DgroupId=包的groupID(要和pom.xml设置的一样,下同) -DartifactId=包的artifaceId -Dversion=包的version  -Dpackaging=包的类型,一般是jar(注意空格)如下面所示

[java] view plain copy
  1. mvn install:install-file -Dfile=D:\mvn\json_simple-1.1.jar -DgroupId=json_simple -DartifactId=json_simple -Dversion=1.1 -Dpackaging=jar  
当然也可以直接使用下面的方法,直接引用:
[java] view plain copy
  1. <dependency>  
  2.             <groupId>json_simple</groupId>  
  3.             <artifactId>json_simple</artifactId>  
  4.             <version>1.1</version>  
  5.             <scope>system</scope>  
  6.             <systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/javabuilder.jar</systemPath>  
  7. < /dependency>
原创粉丝点击