简体   繁体   English

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

[英]Adding Jar File to WEB-INF/lib

I new in Eclipse,Java and Linux. 我是Eclipse,Java和Linux的新手。 I search about this issue but I don't reach to answer. 我搜索这个问题,但我没有回答。 I want to write a program that manipulate HBase Tables. 我想编写一个操作HBase表的程序。 So I have some Jar files that they related to the HBase. 所以我有一些与HBase相关的Jar文件。 In ordinary Java application I add Jar files through following instruction 在普通的Java应用程序中,我通过以下指令添加Jar文件

Build Path -> Configuration Build Path -> Add External Jars 构建路径 - >配置构建路径 - >添加外部JAR

So in Dynamic Web Project sound like different. 所以在Dynamic Web Project中声音就像不同。 after some search I understand the Jar files must be added in WEB-INF/lib or in %TOMCAT_HOME%/lib. 经过一些搜索后,我了解Jar文件必须添加到WEB-INF / lib或%TOMCAT_HOME%/ lib中。 so I get answer from %TOMCAT_HOME%/lib but really stuck about how to add jar files in WEB-INF/lib. 所以我从%TOMCAT_HOME%/ lib得到了答案,但我真的不知道如何在WEB-INF / lib中添加jar文件。 I copy all jar files in the folders but it doesn't work. 我复制文件夹中的所有jar文件,但它不起作用。

please help me in detail. 请详细帮我。

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... 然后只需刷新您的项目并重新启动服务器然后部署项目它将正常工作...

To add jars in eclipse you have two options: 要在eclipse中添加jar,您有两个选择:

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

Use any one of them. 使用其中任何一个。

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

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

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. 这适合我。

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 . 在eclipse中打开项目时,可以手动将jar文件复制到WEB-INF / lib,然后在修改构建路径时,只需单击“添加jar”按钮并从WEB-INF / lib中引用jar。 By this when you deploy your project to tomcat, your WEB-INF/lib folder gets copied automatically. 将项目部署到tomcat时,会自动复制WEB-INF / lib文件夹。

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

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