使用Tomcat的Eclipse Web-App部署:提供多个项目的依赖关系? [英] Eclipse Web-App Deployment with Tomcat: Providing multiple projects' dependencies?

查看:666
本文介绍了使用Tomcat的Eclipse Web-App部署:提供多个项目的依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Tomcat 6和Eclipse部署我的动态Web应用程序时使用的一些第三方库(JAR文件)有问题。



请注意,我在这样的设置中进行这样的操作:Web应用程序项目直接依赖于这些JAR。



但是,在我的设置中,我有两个Eclipse项目:




  • 核心是一个类库,依赖,让我们说, a.jar

  • web 是Web应用程序,取决于 strong>。



web 的项目设置中,在部署程序集类别,我添加了核心,所以Eclipse(或Tomcat - 我不太确定谁负责的演员在这里)是把 core.jar 进入我的网络应用程序的 libs 目录。



问题是:当我尝试网络应用程序,一个 NoClassD当 core a.jar 访问类时,会引发efFoundError 。我应该怎么做这个?我不认为将 a.jar 放入我的Web应用程序的部署程序集设置页面是正确的解决方案,因为它应该是与网络项目无关,核心项目取决于。



基本上,我正在寻找一个配置Eclipse(Tomcat?)以将 core 的依赖项嵌入到 core.jar 中。关于此的问题是,当我部署我的 web 项目时,会自动生成 core.jar



帮助非常感激。
提前感谢

解决方案

嗯,我已经找到了我自己的答案。

对于那些在将来阅读的人,我将逐步说明,使用我在我的原始消息



首先,打开核心项目的属性页面,然后导航到库 'Java Build Path'设置:





确保添加您的类库 a.jar ,您的核心项目依赖,通过'添加JARs ...'。然后,转到订单和导出标签,然后激活刚刚添加的 a.jar 进行导出。





然后转到部署程序集设置,并在此添加 a.jar ,首先点击添加,然后在Java构建路径条目上,最后选择 a.jar文件。确保输入'../'作为 a.jar 的部署路径:





现在,您完成了核心项目。现在打开您的 web 项目的Java Build Path设置的Projects页面,然后点击Add ...添加您的核心项目:





最后,导航到部署程序集设置页面,按添加...,然后选择项目,然后在下一个屏幕上选择您的核心项目:





你完成了无需将核心依赖关系添加到您的网络项目。


I have a problem providing some third party librarys (JAR-files) I am using when deploying my dynamic web application with Tomcat 6 and Eclipse.

Please note that I -do know- how to do this in a setup, where the web application project -directly- depends on those JARs.

However, in my setup, I have two Eclipse projects:

  • core is a class library and depends on, lets say, a.jar.
  • web is the web application and depends on core.

In the project settings of web, in the Deployment Assembly category, I have added core, so Eclipse (or Tomcat - I'm not quite sure who the responsible actor here is) is putting core.jar into the libs directory of my web application.

The problem is: When I try out the web application, a NoClassDefFoundError is thrown when core accesses classes from a.jar. What am I supposed to do about this? I don't think that putting a.jar into the Deployment Assembly settings page of my web application is the right solution, since it should be of no relevance to the web project, what the core project depends on.

Basically, I am looking for a way to configure Eclipse (Tomcat?) to 'embed' the dependencies of core into core.jar. The problem about this is, that core.jar is generated automatically, when I deploy my web project.

Help is very appreciated. Thanks in advance!

解决方案

Well, I've found the answer on my own meanwhile.

For those reading this in the future I will explain step by step, using the semantics I introduced in my original message:

First, open the properties page of your core project and navigate to the 'Libraries' tab of the 'Java Build Path' settings:

Make sure to add your class library a.jar, your core project depends on, via 'Add JARs...'. Then, go ahead to the 'Order and Export' tab and activate the just added a.jar for exporting.

Then go to the 'Deployment Assembly' settings and also add a.jar here by first clicking on 'Add...', then on 'Java Build Path Entries' and finally selecting a.jar. Make sure to enter '../' as the deploy path for a.jar:

Now you are done with your core project. Now open the 'Projects' page of the 'Java Build Path' settings for your web project and add your core project by clicking on 'Add...':

Finally, navigate to the 'Deployment Assembly' settings page, press 'Add...', then take 'Project' and select your core project on the next screen:

You're done. No need to add your core dependencies to your web project.

这篇关于使用Tomcat的Eclipse Web-App部署:提供多个项目的依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆