How to include custom library into maven local repository?--转
原文地址:https://www.mkyong.com/maven/how-to-include-library-manully-into-maven-local-repository/
There are 2 cases that you need to issue Maven’s command to include a jar into the Maven local repository manually.
- The jar you want to use doesn’t exist in the Maven center repository.
- You created a custom jar, and need to use for another Maven project.
P.S Trust me, there are still many jars that doesn’t support Maven.
Case study
For example, kaptcha, a popular third party Java library, which is used to generate “captcha” image to stop spam, but it’s not available in the Maven center repository.
In this tutorial, we will show you how to install the “kaptcha” jar into your Maven’s local repository.
1. mvn install
Download the “kaptcha“, extract it and copy the kaptcha-version.jar
to somewhere else, for example, c drive. Issue following command :
mvn install:install-file -Dfile=c:\kaptcha-{version}.jar -DgroupId=com.google.code
-DartifactId=kaptcha -Dversion={version} -Dpackaging=jar
Demo.
D:\>mvn install:install-file -Dfile=c:\kaptcha-2.3.jar -DgroupId=com.google.code
-DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing c:\kaptcha-2.3.jar to
D:\maven_repo\com\google\code\kaptcha\2.3\kaptcha-2.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue May 12 13:41:42 SGT 2009
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
Now, the "kaptcha" jar is copied to your Maven local repository.
2. pom.xml
After installed, just declares the kaptcha coordinate in pom.xml
.
<dependency>
<groupId>com.google.code</groupId>
<artifactId>kaptcha</artifactId>
<version>2.3</version>
</dependency>
3. Done
Build it, now the "kaptcha" jar is able to retrieve from your Maven local repository.
How to include custom library into maven local repository?--转的更多相关文章
- 【转】Install Oracle Jdbc driver in your Maven local repository
Install Oracle Jdbc driver in your Maven local repository If you are using Oracle, you must first in ...
- Maven 迁移local repository
1.1 Maven仓库主要有2种: remote repository:相当于公共的仓库,大家都能访问到,一般可以用URL的形式访问,一般默认的地址:http://search.maven.org/ ...
- maven编译项目时提示:cached in the local repository
今天使用命令mvn compile编译maven项目时提示错误信息,部分错误信息如下: ...... was cached in the local repository, resolution wi ...
- Failure to transfer org.apache.maven:maven-archiver:pom:2.5 from http://repo.maven.apache.org/ maven2 was cached in the local repository, resolution will not be reattempted until the update interv
Failure to transfer org.apache.maven:maven-archiver:pom:2.5 from http://repo.maven.apache.org/ mave ...
- Failure to transfer org.apache.maven:maven-archiver:pom:2.5 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval o
pom.xml报错: Failure to transfer org.apache.maven:maven-archiver:pom:2.5 from https://repo.maven.apach ...
- 将jar文件加到Maven的local repository中
对于Maven项目来说,日常使用的多数第三方java库文件都可以从Maven的Central Repository中自动下载,但是如果我们需要的jar文件不在Central Repository中,那 ...
- Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.1.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempt
第一次用 Spring Starter Project 创建一个Spring应用时,POM 文件报错: Project build error: Non-resolvable parent POM f ...
- 如何设置maven的local repository目录
step1:默认会放在~/.m2/repository目录下 (“~”代表用户的目录,比如windows下一般都是C:\Documents and Settings\[你的用户名]\.由于“Docum ...
- [Perl]Can't link/include C library 'ft2build.h', 'freetype', aborting.
原文:http://www.code-by.org/viewtopic.php?f=60&t=284 错误提示 Font-FreeType-0.07>perl Makefile.PL B ...
随机推荐
- Docker的官网在线--中文教程
1.官网界面:https://www.docker.com/tryit/ In this 10-minute tutorial, see how Docker works first-hand: Yo ...
- UVa1585修改版
#include<stdio.h> int main() { int i,k=-1; char a[100]; while(scanf("%s",&a)!=EO ...
- Robot Framework(四)创建测试套件
2.3.1测试用例文件 Robot Framework测试用例是使用测试用例文件中的测试用例表创建的.这样的文件会自动从它包含的所有测试用例中创建一个测试套件.可以有多少测试用例没有上限,但建议少于1 ...
- Java范式1
package Xwxx; public class Person { private String name; private int age; public Person() { } public ...
- springboot实现mongodb上传下载
1.上传: private static Logger log = LoggerFactory.getLogger(MongoDbFSUtil.class); private static final ...
- css+div 绘制多边形
/*1.正方形*/ <div id="square"></div> #square { width: 100px; height: 100px; backg ...
- [CodeForces]981C Useful Decomposition
李煜东dalao今天给我们讲课了QwQ ppt上一道题 英文题说一下题意吧,以后又看不懂了 将一棵树分割成多个简单路径,每个边只能在一条路径上,但至少有一个公共节点. 输出简单路径分割方法/No 由题 ...
- SQLAlchemy小知识点
1.创建数据库模型的时候增加添加上注释SQLAlchemy1.2新增了comment参数telephone = db.Column(db.String(11), nullable=False, com ...
- Zookeeper分布式锁解决方案具体代码
定义一个公共资源订单生成类: package com.itmayiedu.lock; import java.text.SimpleDateFormat; import java.util.Date; ...
- 实现路由器自动登录校园网(edu)
准备工作: (1)一个可以刷openwrt固件的路由器,如大多人使用的crazybox版本的路由. (2)一个可用的edu账号. (3)一个浏览器(firfox,chrome) 下面开始: 一:刷op ...