.jar文件和.war文件有什么区别? 仅仅是文件扩展名还是还有其他的东西?
当前回答
You add web components to a J2EE application in a package called a web application archive (WAR), which is a JAR similar to the package used for Java class libraries. A WAR usually contains other resources besides web components, including: Server-side utility classes (database beans, shopping carts, and so on). Static web resources (HTML, image, and sound files, and so on) Client-side classes (applets and utility classes) A WAR has a specific hierarchical directory structure. The top-level directory of a WAR is the document root of the application. The document root is where JSP pages, client-side classes and archives, and static web resources are stored.
(源)
所以。war是一个。jar,但它包含web应用程序组件,并根据特定的结构进行布局。.war被设计为部署到web应用服务器(如Tomcat或Jetty)或Java EE服务器(如JBoss或Glassfish)。
其他回答
War和jar是Java文件的存档。战争是网络档案,他们运行在网络服务器上。Jar是Java归档文件。
此外,使用嵌入式容器,你可以直接运行一个JAR文件,就像用spring boot运行你的java应用程序一样,设置一个web服务器。但是,对于WAR文件,您需要首先设置一个web服务器,例如Tomcat。
战争——
分发基于java的web应用程序。WAR具有相同的文件 结构作为JAR文件,这是一个单独的压缩文件 包含多个捆绑在其中的文件。
Jar——
jar文件包含库、资源和附件文件 比如属性文件。 WAR文件用于组合jsp、servlet、Java类文件和XML 文件,javascript库,JAR库,静态网页等等 运行应用程序所需的其他资源。
Jar:—Jar只包含.class War: War包含html, js, CSS和.class以及JSP和servlet页面
WAR代表Web应用程序存档
JAR代表Java存档
推荐文章
- 在流中使用Java 8 foreach循环移动到下一项
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 用Java计算两个日期之间的天数
- 如何配置slf4j-simple
- 在Jar文件中运行类
- 带参数的可运行?
- 我如何得到一个字符串的前n个字符而不检查大小或出界?
- 我可以在Java中设置enum起始值吗?
- Java中的回调函数
- c#和Java中的泛型有什么不同?和模板在c++ ?
- 在Java中,流相对于循环的优势是什么?
- Jersey在未找到InjectionManagerFactory时停止工作
- 在Java流是peek真的只是调试?
- Recyclerview不调用onCreateViewHolder
- 将JSON字符串转换为HashMap