如何使 Eclipse 自动将我放在 WEB-INF/lib 文件夹中的 jar 包含到我的项目中?
当我进行 JSP/Servlet 编程时,每当我将第 3 方库放入 WEB-INF/lib 文件夹中时,它们就会自动包含在项目类路径中。在 GWT 中,情况并非如此。有人知道为什么吗?我喜欢这在 JSP 中是多么简单,并且我希望这些 jar 能够以同样的方式自动包含在内。
When I was doing JSP/Servlet programming, whenever I dropped 3rd party libraries into the WEB-INF/lib folder, they were automatically included in the project classpath. In GWT, this is not the case. Anyone know why? I loved how easy this was in JSP and I'd like these jars to be included automatically the same way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用的是 Google Plugin for Eclipse 那么我的理解是 Google Web 应用程序项目与动态Web项目不同,因此行为也不同。因此,如果您的项目依赖于 GWT 和 App Engine SDK 未提供的库,则需要将它们放入
war/WEB-INF/lib
中,并将它们显式添加到您的 Java 构建路径中。If you are using the Google Plugin for Eclipse then my understanding is that a Google Web Application Project is just not the same animal than a Dynamic Web Project and thus behave differently. So if your project depends on libraries not provided by the GWT and App Engine SDKs, you'll need to put them in
war/WEB-INF/lib
and to add them explicitly to your Java build path.在 Eclipse Galileo 中,右键单击 Web 项目并选择构建路径,然后选择 Java EE 模块依赖项并添加 jar。
In Eclipse Galileo, right click the web project and select build path then select the Java EE Module Dependencies and add the jars.
如果您想要在构建路径中自动更新新 jar 的目录,有一种插件技术可以帮助您,请参阅另一篇文章:
Eclipse buildpath 自动获取内部目录的所有 JAR
它对于 JSP 的工作方式如此的原因是因为这就是如何动态 Web 项目就是为了运行而设计的。
“如果删除库路径条目但不删除 JAR 文件,则库条目将自动重新添加到路径中。”来自 http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.wst.webtools.doc.user/topics/ccwebprj.html
There is a plug-in technique that may help you if you want a directory where new jars are automatically updated in your build path, see this other post:
Eclipse buildpath automatically taking all JARs of a internal directory
The reason it works like this for your JSP's is because that is how the Dynamic Web Project was made to behave.
"If you remove a library path entry but not the JAR file, the library entry will be re-added to the path automatically." from http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.wst.webtools.doc.user/topics/ccwebprj.html
您可以采用 Maven 并使用 Maven Eclipse 插件;每当您添加依赖项时,此插件都会更新您的类路径。 Ivy 可能有类似的插件。
You could adopt Maven and use the Maven Eclipse Plugin; this plugin would update your classpath whenever you add a dependency. There may be a similar plugin for Ivy.