在maven 2工程中加入iTextAsian支持(maven添加自定义jar包到本地仓库)
最近需要在工程中加入JasperReports,其中要用到把报表导出为pdf文件的功能。JasperReports内部使用iText来输出pdf文档,而iText对中文是放在单独的包iTextAsian.jar中,于是需要在工程中加入iTextAsian。
上网查找了好几个maven 2的repository,都没有收录iTextAsian,那怎么在自己的工程中加入iTextAsian呢?查找了好久,最后还是在AppFuse的论坛中得到Matt Raible的指点后解决了。主要步骤如下:
1.确保你已经在本地机器上创建了maven 2的本地repository
2.到SourceForge上iText的下载页面(http://sourceforge.net/project/showfiles.php?group_id=15255)下载iTextAsian.jar,放到本地的某个目录里(比如C:\TEMP)
2.在命令行提示符下执行如下命令:
mvn install:install-file -DgroupId=com.lowagie -DartifactId=itextasian -Dversion=1.0 -Dpackaging=jar -Dfile=c:\temp\itextasian.jar
这行命令的意思是把该包安装到maven 2的本地repository中
3.在工程的pom.xml中的<dependencies>一节加入如下代码:






4.重新运行mvn war:war,打包后的工程的jar文件中已经包含了itextasian-1.0.jar了
-------------------------------到这步就可以了,就可以把jar包添加到工程中了----------------------
如果细心一点,在运行mvn war:war时会发现maven尝试到工程的pom.xml文件中指定的repository下载itextasian-1.0.pom。由于这些repository并未收录iTextAsian,也就肯定找不到这个文件。尽管这不是什么大问题,还是有办法来避免:自己为本地repository中的iTextAsian编辑一个pom文件。步骤如下:
1.使用纯文本编辑工具录入如下内容:









2.把这个文件保存到本地repository的com\lowagie\itextasian\1.0目录中,文件名为itextasian-1.0.pom即可
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了