eclipse helios:tomcat项目 - jar不会被导出或发布。运行时可能会导致ClassNotFoundExceptions [英] eclipse helios: tomcat project - jar will not be exported or published. runtime ClassNotFoundExceptions may result

查看:463
本文介绍了eclipse helios:tomcat项目 - jar不会被导出或发布。运行时可能会导致ClassNotFoundExceptions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse Helios,我想知道如何将库项目添加到我的文件夹中,该文件夹将被复制到我编译项目所在的构建目录。

I'm using Eclipse Helios and I was wondering how can I add a library project to my folder that will be copied to the build directory where my compiled project resides.

目前我做了以下事情:


  1. 在我项目的根目录中创建了一个lib目录

  2. 将相关的罐子复制到那个目录

  3. 我的项目 - >属性 - > Java构建路径 - >添加罐子,我添加了该目录中的所有罐子。

添加所有罐子后,我收到了关于每个jar文件的以下警告:

after adding all the jars i got the following warning regarding each of the jar file:

jar will not be exported or published. runtime ClassNotFoundExceptions may result

首先,我如何添加罐子的目录而不是单个罐子?
和第二个问题是如何在编译我的应用程序时正确部署库?!

first of all how can I add the directory of the jars instead of individual jars? and the 2nd question is how can I do that the libraries will be deployed properly when compiling my application ?!

推荐答案

它可以是:

  • a simple refresh issue:

您可以切换到导航器视图,右键单击刷新项目,确保它不在 LIB 目录中,

然后尝试将JAR拖放到 lib 目录中,看看它是否显示。

Can you switch to the navigator view, right-click refresh the project, make sure it's not in the LIB dir,
Then try and drag and drop the JAR into the lib dir and see if it shows up.




  • 流程问题(来自此缓存的博客条目原始的不可用):

    • a process issue (from this cached blog entry, the original one being unavailable):

    • 当您完全控制Web容器/应用程序服务器时,部署jar文件就像删除常用lib文件夹中的文件夹一样简单。

      如果您不将Web应用程序打包为 war 文件然后它就更容易了,因为你只需要放弃你的webapp的 WEB-INF / lib 文件夹中的jar。

      但是如果您无法完全控制您的Web服务器或应用程序服务器,那么您唯一的选择就是将您用过的war文件打包为war文件。

      When you have total control of you web container/app server, deploying jar files is as easy as dropping the folder in your common lib folder.
      If you don't package your web apps as a war file then it's even easier because you only have to drop the jars in the WEB-INF/lib folder of your webapp.
      But if you don't have total control of your web server or application server, your only choice is to package the jars you've used with your war file.

      在使用我最近开发的实用程序(jar文件)开发Web项目时,我遇到了 NoClassDefFound 错误。当然,很明显我找不到我在我的web项目上制作和使用的jar文件(在 CLASSPATH 中不可见)。

      将jar添加到构建路径只消除了编译问题。将jar文件拖到我的Eclipse工作区的lib文件夹中并不是一个好主意。

      在我找到解决方案之前花了我几个小时:

      While developing a web project using my recently developed utility(a jar file), I encountered a NoClassDefFound error. Of course, it's pretty obvious that the jar file I've made and using on my web project could not be found (not visible in the CLASSPATH).
      Adding the jar to the build path only eliminated the compilation problem. Dragging the jar file into the lib folder of my Eclipse workspace isn't a very good idea.
      It took me a couple of hours before I figured out the solution:


      1. 右键单击您的Web项目

      2. 单击属性

      3. 选择J2EE模块依赖项

      4. 单击Web Libraries选项卡

      5. 添加外部jar(如果jar在项目之外)。将在 Jar / Module 下添加一个条目,确保单击复选框(选中)。

      1. Right Click on your web project
      2. Click Properties
      3. Select J2EE Module Dependencies
      4. Click the Web Libraries Tab
      5. Add external jars (if the jar is outside of your project). An entry will be added under Jar/Module, make sure you click on the checkbox (checked).

      一切都应该没问题。我尝试导出到war文件,然后检查内容,我的jar文件确实已经部署了战争。

      And everything should be fine. I tried exporting to a war file and then checked the content and my jar files are indeed deployed with the war.




      • 项目配置问题

      • OP ufk 在评论中提及:

        The OP ufk mentions in the comment:


        我通过以下方式解决了问题:

        I resolved the issue by:


        • 在java构建路径中添加Web App Libraries库

        • 添加所有相关的罐子进入 WebContent / WEB-INF / lib

        这篇关于eclipse helios:tomcat项目 - jar不会被导出或发布。运行时可能会导致ClassNotFoundExceptions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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