`

IVY throws IOException Resetting to invalid mark原因及解决办法

阅读更多

        当Ivy文件大于10K后,执行jar包加载后会报如下错:impossible to resolve dependencies: java.io.IOException: Resetting to invalid mark。

        删除一些注释后,文件小于10K,下载又正常了。

        查找了官方网站说明,确认是一个BUG:https://issues.apache.org/jira/browse/IVY-1289。但后来一想,如果不升级版本,随着依赖的第三方JAR包增多怎么办呢?

        于是想到了将ivy.xml拆成多个文件并修改ant脚本如下,经验证OK。

<!-- 下载或从本地缓存获取第三方包 -->
<target name="get-lib" depends="init,clean-lib-cache,configure-lib" description="下载或从本地缓存获取第三方包">
	<ivy:resolve file="ivy.xml" conf="*" />
	<ivy:retrieve pattern="${build.lib.dir}/[artifact].[ext]" />
	<copy todir="${build.lib.dir}">
		<fileset dir="${ext.lib}">
		</fileset>
	</copy>
</target>

        修改为:

<!-- 下载或从本地缓存获取第三方包 -->
<target name="get-lib" depends="init,clean-lib-cache,configure-lib" description="下载或从本地缓存获取第三方包">
	<ivy:resolve file="ivy-01.xml" conf="*" />
	<ivy:retrieve pattern="${build.lib.dir}/[artifact].[ext]" />
	<echo>********************************</echo>
	<ivy:resolve file="ivy-02.xml" conf="*" />
	<ivy:retrieve pattern="${build.lib.dir}/[artifact].[ext]" />
	<copy todir="${build.lib.dir}">
		<fileset dir="${ext.lib}">
		</fileset>
	</copy>
</target>

        当然,除了这种方式,还可以将get-lib命令拆成两个命令,原get-lib命令依赖拆分后的这两个命令。如下所示:

<!-- =================================================================== -->
<!-- 下载或从本地缓存获取第三方包 -->
<!-- =================================================================== -->
<target name="get-lib" depends="get-lib1,get-lib2"/> 
          
<target name="get-lib1" depends="init,clean-lib-cache,configure-lib" description="下载或从本地缓存获取第三方包">
    <ivy:retrieve pattern="${build.lib.dir}/[artifact].[ext]" />
</target>
    
<target name="get-lib2" description="下载或从本地缓存获取第三方包">
    <ivy:resolve file ="ivy2.xml"  />  
    <ivy:retrieve pattern="${build.lib.dir}/[artifact].[ext]" />
</target>

 

Ivy与Ant集成学习资料:http://blog.csdn.net/lisonghua/article/details/4770260

分享到:
评论

相关推荐

    用Java实现多线程服务器程序

    Java有关网络的类及接口定义在java.net包中。客户端软件通常使用java.net包中的核心类Socket与服务器的某个端口建立连接,而服务器程序不同于客户机,它需要初始化一个端口进行监听,遇到连接呼叫,才与相应的客户机...

    java文件操作大全.txt

    public void createFile(String path,String filename) throws IOException...{ File file=new File(path+"/"+filename); if(!file.exists()) file.createNewFile(); } /** *//**创建新文件 * @param ...

    Java文件处理工具类--FileUtil

    public static byte[] readFileBinary(InputStream streamIn) throws IOException { BufferedInputStream in = new BufferedInputStream(streamIn); ByteArrayOutputStream out = new ByteArrayOutputStream...

    大数据平台构建:一个简单的MapReduce程序.pptx

    public void reduce(Text key, Iterable&lt;IntWritable&gt; values, Context context) throws IOException, InterruptedException {…} 二、代码实现 对于main函数的调用。 Main方法的实现 Configuration conf = new ...

    编译原理第二版 龙书 附录 编译器前端 源码

    和附录上是一模一样的,适合初学者,java代码,简单易懂。直接导入即可使用。注意:其编译的对象即语法并非C语言,而是附录中定义的文法,请自行看书理解。

    PhoneBooks

    public byte[] serialize() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeUTF(userName); dos.writeUTF...

    停车场管理系统(java).docx

    public class Method { private int intinput() throws IOException,NumberFormatException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str=br.readLine(); int i=Integer...

    用Java语言开发的网络蚂蚁,很实用哦

    public DownLoad(String objFile,long nStartPos) throws IOException{ this.nStartPos=nStartPos; this.objFile=objFile; rf=new RandomAccessFile(objFile,"rw"); // rf.seek(nStartPos); } public ...

    SSD3答案 完整版

    public static void main(String[] args) throws IOException { ShoppingCartApplication application = new ShoppingCartApplication(); application.run(); } private void run() throws IOException { ...

    利用命令行参数解一元三次方程

     void print()throws IOException  {  System.out.println("求解一元三次方程");  Scanner sLine=new Scanner(System.in);  {  SolveEquation.SolveCubicEquation fc=new SolveEquation().new  ...

    异常处理throws关键字

    hrows关键字通常被应用在声明方法时,用来指定可能抛出的异常,throws 用于抛出方法层次的异常,并且直接由些方法调用异常处理类来处理该异常

    SpringMVC文件上传下载

    public String upload(@RequestParam("myfiles") MultipartFile myfiles) throws IOException{ System.out.println(user.getBeanName()); System.out.println(user.getBeanFactory()); if(!myfiles....

    用Java 写的弹珠游戏

    就是用Java写的一个手机游戏 请各位多多改善

    java throws声明异常实例一

    java throws声明异常实例一 java throws声明异常实例一

    java一个论坛的源码

    * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response...

    购物网站系统

    * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding...

    文件加密解密算法(Java源码)

    private void encryptData(String filename,String encryptfile) throws IOException, InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, ...

    commons-httpclient-3.0.1--java网络开发

    import java.io.IOException; import org.apache.commons.httpclient.params.HttpClientParams; import org.apache.commons.logging.Log; public class HttpClient { // Fields private static final Log LOG; ...

    JBMP在MyEclipse中应用(1)

    * @throws IOException */ public void deployProcessDefinition(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String xml = request....

Global site tag (gtag.js) - Google Analytics