Java 将 Jar 文件添加到 WEB-INF/lib

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9733027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 06:52:11  来源:igfitidea点击:

Adding Jar File to WEB-INF/lib

javaeclipsejsphbase

提问by Mahdi

I new in Eclipse,Java and Linux.I search about this issue but I don't reach to answer. I want to write a program that manipulate HBase Tables. So I have some Jar files that they related to the HBase. In ordinary Java application I add Jar files through following instruction

我是 Eclipse、Java 和 Linux 的新手。我搜索了这个问题,但我没有回答。我想编写一个操作 HBase 表的程序。所以我有一些与 HBase 相关的 Jar 文件。在普通的 Java 应用程序中,我通过以下说明添加 Jar 文件

Build Path -> Configuration Build Path -> Add External Jars

构建路径 -> 配置构建路径 -> 添加外部 Jar

So in Dynamic Web Project sound like different. after some search I understand the Jar files must be added in WEB-INF/lib or in %TOMCAT_HOME%/lib. so I get answer from %TOMCAT_HOME%/lib but really stuck about how to add jar files in WEB-INF/lib. I copy all jar files in the folders but it doesn't work.

所以在动态 Web 项目中听起来好像不同。经过一番搜索,我了解到必须在 WEB-INF/lib 或 %TOMCAT_HOME%/lib 中添加 Jar 文件。所以我从 %TOMCAT_HOME%/lib 得到了答案,但我真的不知道如何在 WEB-INF/lib 中添加 jar 文件。我复制了文件夹中的所有 jar 文件,但它不起作用。

please help me in detail.

请详细帮助我。

采纳答案by Nirav Valera

you are doing right....

你做得对....

Build Path -> Configuration Build Path -> Add External Jars

In "Order and Export" tab click on select all...

在“订购和导出”选项卡中单击全选...

or coping file into WEB-INF/lib 

Then just refresh your project and restart the server then deploy the project it will work fine...

然后只需刷新您的项目并重新启动服务器,然后部署该项目即可正常工作...

回答by Rahul Borkar

You can copy jar files manually to WEB-INF/lib when you have your project open in eclipse, then while modifying build path, just click "add jars" button and refer a jar from WEB-INF/lib . By this when you deploy your project to tomcat, your WEB-INF/lib folder gets copied automatically.

当您在 Eclipse 中打开项目时,您可以手动将 jar 文件复制到 WEB-INF/lib ,然后在修改构建路径时,只需单击“添加 jars”按钮并从 WEB-INF/lib 引用一个 jar。这样,当您将项目部署到 tomcat 时,您的 WEB-INF/lib 文件夹将被自动复制。

回答by Vinay

as Cultor said its right process but you must be refresh project after adding jar files.

正如Cultor所说,它的过程是正确的,但您必须在添加jar文件后刷新项目。

Build Path -> Configuration Build Path -> Add External Jars

构建路径 -> 配置构建路径 -> 添加外部 Jar

回答by sandipchandanshive

To add jars in eclipse you have two options:

要在 Eclipse 中添加 jars,您有两个选择:

  1. Right click on project got to properties-->click on java build path --> configure build path--> Libraries --> and select add external jars button. It will open a window where you can add all your jars required.
  2. Second option is to paste jars directly to lib folder. lib folder is in Web Content --> WEB-INF --> lib.
  1. 右键单击项目到属性--> 单击 java 构建路径--> 配置构建路径--> 库--> 并选择添加外部 jars 按钮。它将打开一个窗口,您可以在其中添加所需的所有罐子。
  2. 第二种选择是将 jars 直接粘贴到 lib 文件夹。lib 文件夹在 Web Content --> WEB-INF --> lib 中。

Use any one of them.

使用其中任何一种。

回答by Rahi Javaid

You can drag the MySQL jar file from external folder where it is located in your computer into the lib of your project..

您可以将 MySQL jar 文件从它位于计算机中的外部文件夹拖到项目的 lib 中。

回答by Abhinandan Singh

If a path to the jar file is too long it will not paste that jar file.

如果 jar 文件的路径太长,则不会粘贴该 jar 文件。

Paste the jar file on the desktop and try again.

将 jar 文件粘贴到桌面上并重试。

This works for me.

这对我有用。