[英]including jar file in ivy dependencies
I am using netbeans 7.1.1 and ivy together. 我正在一起使用netbeans 7.1.1和常春藤。 I have ivy.xml file as follows :
我有ivy.xml文件,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
<info module="Laitsv3second" organisation="Laitsv3second" revision="1.0"/>
<dependency org="org.apache.httpcomponents" name="httpclient" rev="latest.integration">
</dependency>
</ivy-module>
Now the problem is as follows : my project uses log4j library as well. 现在问题如下:我的项目也使用log4j库。 and when I run the project I get an error as follows :
当我运行项目时,出现如下错误:
java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest
the downloaded httpclient library contains this class org.apache.http.client.methods.HttpUriRequest.java but this is an interface and hence this error is arising. 下载的httpclient库包含此类org.apache.http.client.methods.HttpUriRequest.java,但这是一个接口,因此会出现此错误。 I observed that ivy links sources.jar in ivy libraries which contains java interface but what I want is httpclient.jar to be included in the project which is a compiled version of sources containing
.class
files. 我观察到,常春藤在包含Java接口的常春藤库中链接sources.jar,但是我想要的是将httpclient.jar包含在项目中,该项目是包含
.class
文件的源的编译版本。 Is there any way this is possible? 有什么办法可行吗?
First of all your ivy file is invalid. 首先,您的常春藤文件无效。 You're missing the enclosing "dependencies" tag:
您缺少随附的“ dependencies”标签:
<ivy-module version="2.0">
<info module="Laitsv3second" organisation="Laitsv3second" revision="1.0"/>
<dependencies>
<dependency org="org.apache.httpcomponents" name="httpclient" rev="latest.integration"/>
</dependencies>
</ivy-module>
What I suspect is your real issue is that you are not setting your classpath correctly within your ANT build. 我怀疑您的真正问题是您在ANT构建中未正确设置类路径。 Impossible to diagnose further based on the available information.
不可能根据可用信息进一步诊断。
What I would suggest is use the working example in the following answer: 我建议在以下答案中使用工作示例:
I recommend checking out how it uses configurations in the ivy file and ivy tasks like: 我建议检查一下它如何使用ivy文件中的配置以及ivy任务,例如:
The above mentioned error is because ivy libraries are not added to the java classpath. 上面提到的错误是因为ivy库未添加到java类路径中。 This issue is reported on ivyBeans website.
此问题已在ivyBeans网站上报告。 Here are the details of the issue.
以下是问题的详细信息。 As stated here I too solved this problem by turning 'compile on save' option off in the netbeans.
如此处所述,我也通过在netbeans中关闭“在保存时编译”选项解决了这个问题。 I thought this solution might help others hence posted.
我认为此解决方案可能会帮助其他人,因此发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.