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 <dependency> <groupId>123456</groupId> <artifactId>123456</artifactId> <version>1.0</version> </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 <project> <modelVersion>1.0.0</modelVersion> <groupId>123456</groupId> <artifactId>123456</artifactId> <version>1.0</version> </project>
5 在你的项目的pom.xml依赖中引入就行了
[html] view plain copy <dependency> <groupId>123456</groupId> <artifactId>123456</artifactId> <version>1.0</version> </dependency>
6 如果你的pom.xml报错
然后勾选 force update of snapshots/releases 选项即可。
7 项目代码中使用:
[html] view plain copy boolean b = RegexUtils.checkEmail(email);
8 关于groupId,artifactId怎么写再举一例
jar包的位置
pom.xml中引入
[html] view plain copy <dependency> <groupId>com.taibao</groupId> <artifactId>Butils</artifactId> <version>1.0</version> </dependency>
转载于:https://www.cnblogs.com/sx2zx/p/7284209.html
