Java的配置构建路径或WEB-INF / lib文件夹 [英] Java Configuring Build Paths or WEB-INF/lib folder

查看:744
本文介绍了Java的配置构建路径或WEB-INF / lib文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了很多的教程和应用,把自己的罐子构建路径内而其他人把它放在自己的WEB-INF / lib文件夹里面,是否有显著差异?什么是两者的利弊?什么是指标,我把libs文件夹里面一定罐子,把罐子在构建路径?

I've seen a lot of tutorials and applications that put their jars inside a build path while others put it inside their web-inf/lib folder, Are there any significant difference? What are the pros and cons of both? What is an indicator for me to put a certain jar inside the libs folder and put the jar in the build path?

推荐答案

与WEB-INF文件夹的应用程序是一个Web应用程序。这意味着它会被打包为一个WAR文件,并部署在服务器上。

An application with WEB-INF folder is a web application. Meaning it will be packed as a WAR file and deployed on a server.

如果您使用的是像日食的IDE,并导出项目作为WAR文件,它会自动采取的lib文件夹下的罐子和与战收拾他们,这将使其可在服务器上运行的应用程序(在WEB-INF / lib目录罐子都包含在应用程序类路径)。

If you are using an IDE like eclipse, and you export the project as a WAR file, it will automatically take jars under the lib folder and pack them with the WAR and that will make them available for the application running on the server (jars under WEB-INF/lib are included in the application classpath).

如果你只是把它们放在其他地方,包括他们在构建路径,当你导出项目必须声明要在构建路径的罐子被包括在内。

If you just put them anywhere else and include them in the build path, when you export the project you have to declare that you want the jars in the build path to be included as well.

基本上没有大的区别,但如果你知道你需要这个jar在运行时(也就是将应用程序部署到服务器之后),最好是把它放在WEB-INF / lib文件夹下。

Basically, there is no big difference but if you know you need this jar in runtime (i.e. after deploying the application to the server), it is better to put it under the WEB-INF/lib folder.

这篇关于Java的配置构建路径或WEB-INF / lib文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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