简体   繁体   English

Eclipse + Java + Tomcat-如何设置动态Web项目以引用其他Java项目

[英]Eclipse+Java+Tomcat - How to setup dynamic web project to refer other java projects

I'm creating a web app, for which I have created a dynamic web project in Eclipse. 我正在创建一个Web应用程序,为此我在Eclipse中创建了一个动态Web项目。 I have also created two java projects, which serve different business purposes. 我还创建了两个java项目,它们分别用于不同的业务目的。 I want my dynamic web project to use these projects as well. 我希望动态Web项目也使用这些项目。

Below are the projects i've created 以下是我创建的项目

  1. myapp-core (Java project that has all my core components) myapp-core(具有我所有核心组件的Java项目)
  2. myapp-db (All classes related to DB calls go here) myapp-db(与数据库调用有关的所有类都在这里)
  3. myappWeb (Dynamic web project which will have only presentation logic) myappWeb(只有演示文稿逻辑的动态Web项目)

The point is, I've created all these projects and the classes within them. 关键是,我已经创建了所有这些项目以及其中的类。 I have also added myapp-core and myapp-db projects to my myaddWeb's classpath, and am now free of any compilation errors. 我还将myapp-core和myapp-db项目添加到了myaddWeb的类路径中,现在没有任何编译错误。

However, when I deploy this on Tomcat, I get java.lang.ClassNotFoundException for org.slf4j.LoggerFactory 但是,当我在Tomcat上部署它时,我得到java.lang.ClassNotFoundException for org.slf4j.LoggerFactory

Now, all three projects have logging, for which I have added slf4j and logback related jars to the build paths of each project (separately). 现在,所有三个项目都有日志记录,为此,我分别将slf4j和与logback相关的jar添加到每个项目的构建路径中。

All my projects are referencing common libraries, like guava, apache poi, etc., which I have associated with each project separately. 我所有的项目都引用了通用库,例如​​guava,apache poi等,这些库与每个项目分别关联。

Am I missing anything here? 我在这里想念什么吗? Can anyone guide me what is the exact setup that needs to be done for such a framework? 任何人都可以指导我为此类框架进行哪些确切的设置?

Thanks Sriram 谢谢斯里拉姆

Please follow below mentioned steps for all 3 projects : 1. Right Click on your Project 2. Go to "Java EE Module Dependencies" option. 请对所有3个项目执行以下提到的步骤:1.右键单击您的项目2.转到“ Java EE模块依赖项”选项。 3. Select all jars and Apply changes. 3.选择所有罐子并应用更改。

If "Java EE Module Dependencies" is not there, try "Web Deployment Assembly" which does the same thing. 如果“ Java EE模块依赖项”不存在,请尝试执行相同操作的“ Web部署程序集”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM