1 首先找到你的maven的配置文件{你maven的路径}\conf\settings.xml,然后打开settings.xml,查看你存放本地jar路径的根目录。例如我的maven根目录是C:\Users\user\.m2\localRepository。我自己定义的jar只要按照一定的规则放在这个根目录下就行了,下文会具体介绍。可以从eclipse中找到

 

 

2 假如你自定义的jar包是123456.jar,你想在你项目的pom.xml中这样引入你的jar包

 

[html] view plain copy
 
  1. <dependency>    
  2.             <groupId>123456</groupId>    
  3.             <artifactId>123456</artifactId>    
  4.             <version>1.0</version>    
  5. </dependency>   


3 在你的根目录文件夹下建立如下文件夹

 

在根目录C:\Users\user\.m2\localRepository\  创建123456文件夹 ---->再创建123456文件夹----->再创建1.0文件夹

最后把123456.jar放到1.0文件夹下

转载请标明链接:http://blog.csdn.net/wabiaozia?viewmode=contents

如下图所示

4 把123456.jar改为123456-1.0.jar,并创建文件123456-1.0.pom。这里注意,创建的文件后缀是点pom而不是点xml(是" . pom"不是".xml")。

然后在123456-1.0.pom中写如下内容

 

[html] view plain copy
 
  1. <project>   
  2.   <modelVersion>1.0.0</modelVersion>   
  3.   <groupId>123456</groupId>   
  4.   <artifactId>123456</artifactId>   
  5.   <version>1.0</version>   
  6. </project>   

5 在你的项目的pom.xml依赖中引入就行了

 

 

[html] view plain copy
 
  1. <dependency>    
  2.             <groupId>123456</groupId>    
  3.             <artifactId>123456</artifactId>    
  4.             <version>1.0</version>    
  5. </dependency>  


6 如果你的pom.xml报错

 


然后勾选 force update of snapshots/releases 选项即可。

7 项目代码中使用:

 

[html] view plain copy
 
  1. boolean b = RegexUtils.checkEmail(email);  

 

8 关于groupId,artifactId怎么写再举一例

jar包的位置

pom.xml中引入

 

[html] view plain copy
 
    1. <dependency>  
    2.           <groupId>com.taibao</groupId>  
    3.           <artifactId>Butils</artifactId>  
    4.           <version>1.0</version>  
    5. </dependency>  
posted on 2017-08-04 11:42  ..SunXin  阅读(485)  评论(0编辑  收藏  举报