Java 如何将 JAR 文件添加到 Eclipse 中的 web-inf/lib 文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4440479/
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-14 17:31:18  来源:igfitidea点击:

How can I add JAR files to the web-inf/lib folder in Eclipse?

javaeclipse

提问by ferz

I'm using Eclipse and I need to be able to add Java libraries (JAR files) into my web application's WEB-INF/libfolder. How do I achieve this?

我正在使用 Eclipse,我需要能够将 Java 库(JAR 文件)添加到我的 Web 应用程序的WEB-INF/lib文件夹中。我如何实现这一目标?

采纳答案by Mike G

  • Add the jar file to your WEB-INF/lib folder.
  • Right-click your project in Eclipse, and go to "Build Path > Configure Build Path"
  • Add the "Web App Libraries" library
  • 将 jar 文件添加到您的 WEB-INF/lib 文件夹。
  • 在 Eclipse 中右键单击您的项目,然后转到“构建路径 > 配置构建路径”
  • 添加“Web 应用程序库”库

This will ensure all WEB-INF/lib jars are included on the classpath.

这将确保所有 WEB-INF/lib jar 都包含在类路径中。

回答by morja

They are automatically added to the project classpath if its a web project. Sometimes it does not work properly, a refresh or close/open of the project helps.

如果是 Web 项目,它们会自动添加到项目类路径中。有时它无法正常工作,刷新或关闭/打开项目会有所帮助。

if its not a web project you can right click on the library and go to "Build Path" -> "Add to Build Path"

如果它不是网络项目,您可以右键单击库并转到“构建路径”->“添加到构建路径”

回答by madhairsilence

Found a solution. This problem happens, when you import a project.

找到了解决办法。导入项目时会发生此问题。

The solution is simple

解决方法很简单

  1. Right click -> Properties
  2. Project Facets -> Check Dyanmic Web Module and Java Version
  3. Apply Setting.
  1. 右键单击-> 属性
  2. 项目方面 -> 检查动态 Web 模块和 Java 版本
  3. 应用设置。

Now you should see the web app libraries showing your jars added.

现在您应该会看到显示您添加的 jar 的 Web 应用程序库。

回答by G O'Rilla

Pasting the jar files in WebContent\WEB-INF\lib via the file system was the only way it worked for me.

通过文件系统将 jar 文件粘贴到 WebContent\WEB-INF\lib 中是它对我有用的唯一方法。

They then appeared under the Deployed Resources and WebContent lib sub-folders.

然后它们出现在 Deployed Resources 和 WebContent lib 子文件夹下。

When I looked, the build path had the jars in the Web App Libraries and everything built and ran fine.

当我查看时,构建路径在 Web 应用程序库中包含 jar,并且所有内容都构建并运行良好。

回答by ifti

Check under project properties -> deployment assembly if jar file are under deployed path- WEB-INF/lib if not use add button and add jar under WEB-INF/lib

在项目属性->部署程序集下检查jar文件是否在部署路径-WEB-INF/lib下如果不使用添加按钮并在WEB-INF/lib下添加jar

sometime eclipse (in my case Juno Service Release 2 ) was not doing it for me so i did manually. this worked for me.

有时 eclipse(在我的情况下 Juno Service Release 2)并没有为我做这件事,所以我手动做了。这对我有用。

回答by Vikram Belde

From the ToolBar to go Project> Properties>Java Build Path > Add External Jars. Locate the File on the local disk or web Directory and Click Open.

从 ToolBar 去 Project> Properties>Java Build Path > Add External Jars。在本地磁盘或 Web 目录中找到该文件,然后单击“打开”。

This will automatically add the required Jar files to the Library.

这将自动将所需的 Jar 文件添加到库中。

回答by Discode

In case this helps anyone, if you are using a Git repo, make sure the jars make it into the WEB-INF/lib INSIDE the git repo and not just in the project WEB-INF/lib

如果这对任何人有帮助,如果您使用的是 Git 存储库,请确保将 jar 放入 WEB-INF/lib 中 git 存储库内,而不仅仅是在项目 WEB-INF/lib 中

回答by Saurabh Saha

  1. add the jar to WEB-INF/lib from file structure
  2. refresh the project, you should see the jar now visible under the WEB-INF/lib folder.
  1. 将 jar 从文件结构添加到 WEB-INF/lib
  2. 刷新项目,您应该会在 WEB-INF/lib 文件夹下看到现在可见的 jar。

回答by Shaina Raza

add the jar to WEB-INF/lib from file structure refresh the project, you should see the jar now visible under the WEB-INF/lib folder.

将 jar 从文件结构添加到 WEB-INF/lib 刷新项目,您应该看到 jar 现在在 WEB-INF/lib 文件夹下可见。

this is the best solution that worked for me

这是对我有用的最佳解决方案

回答by Umesh Bhutada

Add the jar file to your WEB-INF/lib folder. Right-click your project in Eclipse, and go to "Build Path > Configure Build Path" Add the "Web App Libraries" library This will ensure all WEB-INF/lib jars are included on the classpath. helped me..

将 jar 文件添加到您的 WEB-INF/lib 文件夹。在 Eclipse 中右键单击您的项目,然后转到“构建路径 > 配置构建路径” 添加“Web 应用程序库”库 这将确保所有 WEB-INF/lib jar 都包含在类路径中。帮助过我..

Drag and drop in WEB-INF/lib folder and restart eclipse ans start webservice then create client

拖放到 WEB-INF/lib 文件夹并重启 eclipse ans start webservice 然后创建客户端