我有一个动态网络项目,我们将称为“项目A”和另一个常规的java项目,我们将称为“项目B”在eclipse。我已经通过进入项目属性Properties -> Deployment Assembly -> Add -> Project将项目b添加到项目A中。这样可以将jar "project B.jar“添加到项目A/WEB/lib文件夹中。但是,“项目B”上配置的外部jar文件不包含在“ProjectB.jar”中。此外,我去了project b -> Properties -> Java Build Path -> Order and Export,检查了“项目B”所需的所有依赖项,但它仍然没有将它们包含在jar中。如何让eclipse将这些jars包含在“ProjectB.jar”文件中。
如果您需要知道,我使用的是eclipse,而我们没有在这个项目中使用mavin,这是我们所需要的唯一一个jar。提前谢谢。
发布于 2015-06-22 06:51:20
您应该将项目B转换为分面形式(转到项目属性,“properties”->“转换为分面形式.”)。唯一需要的方面是"Java“和”实用程序模块“。如果我没记错的话,Eclipse会给您一个警告,在项目A的运行时,这些额外的JAR依赖项可能会丢失,给出了快速修复选项来将它们作为依赖项添加。这将为每个引用的JAR文件向项目B的.classpath文件添加一个.classpath元素,例如:
<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.9.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="../"/>
</attributes>
</classpathentry>不需要包含的JAR将得到以下属性:
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>如果没有收到上述警告,则可以直接添加attributes元素。注:这都是为了Eclipse露娜,但我知道至少在开普勒,它已经像这样工作了。
https://stackoverflow.com/questions/30948356
复制相似问题