用Eclipse3.3+Ant1.7.0,在build.xml文件中使用ftp将包发到远程服务器上时总是出错,出错信息为:
“Could not create type ftp due to java.lang.NoClassDefFoundError:
org/apache/commons/net/ftp/FTPClientConfig”
结果Google了N久,知道是少了两个包:commons-net-1.4.1.jar和jakarta-oro-2.0.8.jar
把这两个包放到Eclipse的Ant的lib目录下,在Eclipse重新执行ant,问题依然存在。结果又Google了很久,最终,在一篇外国博文 中找到解决方法,原文如下
“I had the same error message, but only in Eclipse (version 3.3).
I did not get the error on command line. I had setup up ANT_HOME variable correctly and copied the jakarta-oro-2.0.8.jar and commons-net-1.4.1.jar to %ANT_HOME%\lib
However it seems that the ANT Eclipse module does not automatically parse the %ANT_HOME%\lib directory for new jars and I had to add them manually
preferences->Ant->Runtime, Classpath tab, Ant Home Entries -> Add External JARs...
Then it worked. ”
本文详细介绍了在使用Eclipse 3.3和Ant 1.7.0进行FTP发布时遇到的Could not create type ftp due to java.lang.NoClassDefFoundError错误,通过分析得知原因在于缺少commons-net-1.4.1.jar和jakarta-oro-2.0.8.jar这两个依赖库。文章提供了在Eclipse中手动添加这两个库并配置Ant运行时环境的方法,最终成功解决了问题。
246

被折叠的 条评论
为什么被折叠?



