GlassFish/Payara 4.x 中的 glassfish-application.xml 和 glassfish-web.xml 有什么区别?

What's the difference between glassfish-application.xml and glassfish-web.xml in GlassFish/Payara 4.x?

对于所有可以想象的实现对("What's the difference between Tomcat and GlassFish"、"What's the difference between GlassFish and JBoss" 等),Java EE 和 Web 配置文件之间的差异有大量解释,非常清楚大部头书。 glassfish-web.xml vs sun-web.xml vs web.xml as well as The difference between web.xml, beans.xml, applicationContext.xml, etc 有很好的问题,但它们都 link 到 GlassFish 3.x 文档[1]。

我想就

发表一些明确的声明

我认为 Payara 和 GlassFish 之间没有区别,因为前者被设计为直接替代品 - 事实上 documentation is practically not found by google 对于 Payara 和 GlassFish 4.x 是一样的。


[1] 这是 GlassFish 的 主要问题 - 大多数时候只有 3.x 文档可以通过手册、博客中的 link 获得和 SO 问题,您必须假设它可能无法正常工作,因为某些事情从 3.x 变为 4.x,这导致 n 个问题的复杂度为 2^n。

precedence between glassfish-application.xml and glassfish-web.xml, meaning does one override the other (it could be logical that web overrides application because the classloading order is inverted) or are options picked from both?

glassfish-application.xml 适用于 .ear 个文件,而 glassfish-web.xml 适用于 .war 个文件。对于 .ear 中的 .warglassfish-web.xml 将覆盖 glassfish-ejb.xml.

中声明的设置

possible locations where I can expect the files to be picked up. I assume / in the ear for the application and /WEB-INF/ in the war (inside the ear) for the application descriptor

如果您的意思是文件应该位于何处,则 glassfish-application.xml 应该放在 .earMETA-INF 内,与 MANIFEST.MF 并排,而glassfish-web.xml 应放在 WEB-INF 内,与 beans.xml.

并排

Is it possible to specify any values in both files which can be specified in other files, like web.xml or beans.xml and if yes, what's the precedence, then?

是的,标准的 JavaEE 部署描述符,因此 web.xmlbeans.xml 等受到尊重,但是如果有特定于服务器的部署描述符(即 glassfish-web.xml),它们将被覆盖.

What's the situation in a war packaged (as opposed to ear packaged) Java EE application?

在 war 打包的应用程序中,您应该坚持使用 glassfish-web.xml 部署描述符。这将覆盖 JavaEE web.xml 部署描述符中设置的值,但两者都将被读取。

I assume that there's no difference between Payara and GlassFish because the former is designed to be a drop-in replacement - the fact that documentation is practically not found by google is the same for Payara as for GlassFish 4.x.

由于 Payara Server 派生自 GlassFish,我们仅记录扩展或修改默认行为的区域。因此,GlassFish 4 文档 https://javaee.github.io/glassfish/documentation4 can be used for any areas not mentioned within the Payara Server documentation https://docs.payara.fish/。我同意这确实让您很难找到所需的内容,尤其是在 GlassFish 部署指南没有明确说明的情况下。事实上,GlassFish 5 文档的很大一部分似乎与 3.1.2 没有变化,因此您可能离当前的答案不远了。