JAR与WAR文件规范 [英] JAR vs WAR file specification
问题描述
我注意到WAR文件应该包含 classes /
和 lib /
包含其类文件根目录的目录依赖关系。
I noticed that WAR files are supposed to have classes/
and lib/
directories for containing their classfile root and dependencies, respectively.
我还注意到,JAR包含这样的 lib /
目录并不常见并且包含它们自己的依赖项。
I also noticed that it is not common practice for JARs to contain such a lib/
directory and to contain their own dependencies.
所以现在我想知道为什么JAR不应该/通常不包含它们自己的依赖项,但是WAR文件是期待到。除非我遗漏了某些内容,否则它们都要求它们的依赖项在运行时位于类路径上(如果它们缺少依赖项,JAR将不会运行,就像WAR不会运行一样)。所以对我来说,将依赖项放在WAR文件中的所有参数也适用于JAR。
So now I'm wondering why JARs shouldn't/usually-don't contain their own dependencies, but WAR files are expected to. Unless I'm missing something, both require their dependencies to be on the classpath at runtime (JARs won't run if they're missing dependencies, just like WARs won't run). So to me, all the arguments for putting dependencies in a WAR file also apply to a JAR.
我在这里没有得到什么?!?
What am I not "getting" here?!?
推荐答案
从概念的角度来看:
A jar
通常表示可以使用的单个库,可能有也可能没有依赖项。
但是这个想法是可以在 jar $中提供特定的功能库C $ C>。
From a conceptual point of view:
A jar
typically represents a single library which can be used and may or may not have dependencies.
But the idea is that a specific functionality can be provided as a library in a jar
.
A war
本身就是一个应用程序,因此它应该包含所有依赖项
A war
is an application by itself and as such it should include all the dependencies
这篇关于JAR与WAR文件规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!