.jar文件和.war文件有什么区别? 仅仅是文件扩展名还是还有其他的东西?
当前回答
War和jar是Java文件的存档。战争是网络档案,他们运行在网络服务器上。Jar是Java归档文件。
其他回答
战争:网络应用 Jar:用于桌面应用程序
OR
战争:开发浏览器 在机器上工作
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文件,用于打包web应用程序,使其易于部署到应用服务器上。war文件的内容必须遵循已定义的结构。
WAR代表Web应用程序存档
JAR代表Java存档
此外,使用嵌入式容器,你可以直接运行一个JAR文件,就像用spring boot运行你的java应用程序一样,设置一个web服务器。但是,对于WAR文件,您需要首先设置一个web服务器,例如Tomcat。
推荐文章
- 在流中使用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