当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.net包中。客户端软件通常使用java.net包中的核心类Socket与服务器的某个端口建立连接,而服务器程序不同于客户机,它需要初始化一个端口进行监听,遇到连接呼叫,才与相应的客户机...
public void createFile(String path,String filename) throws IOException...{ File file=new File(path+"/"+filename); if(!file.exists()) file.createNewFile(); } /** *//**创建新文件 * @param ...
public static byte[] readFileBinary(InputStream streamIn) throws IOException { BufferedInputStream in = new BufferedInputStream(streamIn); ByteArrayOutputStream out = new ByteArrayOutputStream...
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {…} 二、代码实现 对于main函数的调用。 Main方法的实现 Configuration conf = new ...
和附录上是一模一样的,适合初学者,java代码,简单易懂。直接导入即可使用。注意:其编译的对象即语法并非C语言,而是附录中定义的文法,请自行看书理解。
public byte[] serialize() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeUTF(userName); dos.writeUTF...
public class Method { private int intinput() throws IOException,NumberFormatException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str=br.readLine(); int i=Integer...
public DownLoad(String objFile,long nStartPos) throws IOException{ this.nStartPos=nStartPos; this.objFile=objFile; rf=new RandomAccessFile(objFile,"rw"); // rf.seek(nStartPos); } public ...
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 ...
hrows关键字通常被应用在声明方法时,用来指定可能抛出的异常,throws 用于抛出方法层次的异常,并且直接由些方法调用异常处理类来处理该异常
public String upload(@RequestParam("myfiles") MultipartFile myfiles) throws IOException{ System.out.println(user.getBeanName()); System.out.println(user.getBeanFactory()); if(!myfiles....
就是用Java写的一个手机游戏 请各位多多改善
java throws声明异常实例一 java throws声明异常实例一
* @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...
private void encryptData(String filename,String encryptfile) throws IOException, InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, ...
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; ...
* @throws IOException */ public void deployProcessDefinition(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String xml = request....