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 ...
随机推荐
- 3D旋转立方体案例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- linux下使用Android studio启动模拟器时提示 waiting for target device to come online 的问题
方法来自:http://stackoverflow.com/questions/42612468/how-can-i-get-more-information-about-waiting-for-ta ...
- promise待看文档备份
http://swift.gg/2017/03/27/promises-in-swift/ http://www.cnblogs.com/feng9exe/p/9043715.html https:/ ...
- 前端开发app
1.如果是 Angular 那就选 Ionic (一对好 CP) 2.如果是 Vue 那就选 Vux (基于 WeUI)3.如果是 jQuery 那就选 Framework7 (iOS 和 Andro ...
- MongoDB 学习笔记(六):备份与用户管理
一.启动项 1.在启动数据库服务时可以在命令行输入mongod命令,然后直接带一些参数,比如“mongod --dbpath D:\Installations\MongoDB-2.4.6\MongoD ...
- centos7 选定默认启动内核,及删除无用内核
#使用cat /boot/grub2/grub.cfg |grep menuentry 查看系统可用内核 [root@bigapp-slave27 ~]# cat /boot/grub2/grub.c ...
- Ubuntu 终端配置
安装zsh apt install zsh 设置zsh为默认shell chsh -s /bin/zsh 恢复 bash 使用 chsh -s /bin/bash 安装 Oh My Zsh sh -c ...
- 51nod-完美字符串(贪心)
约翰认为字符串的完美度等于它里面所有字母的完美度之和.每个字母的完美度可以由你来分配,不同字母的完美度不同,分别对应一个1-26之间的整数. 约翰不在乎字母大小写.(也就是说字母F和f)的完美度相同. ...
- 使用Ansible安装部署nginx+php+mysql之配置iptables防火墙(0)
前提: 1.已配置好hosts文件且免密码登录 2.需要的yaml文件已上传到主控端 一.使用Ansible配置iptables 1.iptables.yaml文件 --- - hosts: clon ...
- PHP图片验证码处理