Sling 运行 模式的优先顺序

order of precedence of Sling run modes

我对这个问题有疑问

Question: What is the correct order of precedence to setup runmodes in aem? (From left to right, left beign the highest)?

A. System property, Sling properties file, jar file
B. jar file, sling properties file, system property
C. Sling properties file, jar file, system property
D. jar file, System property, Sling properties file

Answer : B

我查阅了各种文档并对此进行了多次实验。

根据Adobe documentation命令是-Sling.properties,系统属性,jar文件

同样,this Adobe doc有一个矛盾的意见-jar文件,sling.properties,系统属性

此外,Apache Sling Doc 表示任何 属性 到选项 D (-D) 的设置方式 n=v 都会覆盖 sling.properties 文件中的相同命名属性。这意味着系统 属性 的优先级高于 sling.properties.

现在,这些都是根据文档,我试验过的是-

我做了一个路径 ${dir}/crx-quickstart/conf 并创建了一个文件 sling.properties 并写了 sling.run.modes=publish。然后将jar文件重命名为cq-author-7502.jar。然后 运行 这个罐子用命令 java -jar cq-author-7502.jar -Dsling.run.modes=prod

这是我的观察:
1. 当 jar 运行s 时,Setting 'sling.run.modes' to 'publish' from sling.properties. 此消息显示在终端中。
2.实例以作者模式启动。并且
3、我在felix console里面查看instance-mode的时候是prod

我完全搞不清楚优先顺序。因为一切对我来说似乎都是矛盾的。

如果有人能对它有所启发,我们将不胜感激..

谢谢

我认为这取决于我们何时检查 运行 模式优先级,在安装时或稍后在 运行ning 实例上以及我们如何启动实例。有2种运行模式。安装时间 运行 模式,自定义 运行 模式。

  • 安装时间 运行 模式 - 如 official run modes documentation and setup instructions 所述,这只能在安装时设置一次。这包括 authorpublishnosamplecontentsamplecontent
  • 自定义 运行 模式 - 自定义 运行 模式,例如devqaprod

我做了一些测试 (AEM 6.1),优先级按以下方式工作

初始设置

  • 启动 jar(通过双击)- 在此您没有选项在 sling.properties 中设置 运行 模式,第一次启动脚本。 JAR 名称优先。
  • 解压 jar 并在启动脚本中将 运行 模式指定为系统属性 - JAR 名称未在此处显示。在此您没有选项可以在 sling.properties 中设置 运行 模式。系统属性优先。

运行实例

  • 即使我们在 JAR 名称中更改 运行 模式,也不会更改安装时的 运行 模式。对于自定义 运行 模式,JAR 文件名不适用。优先顺序是 sling.properties -> 指定 -r 选项(命令行 jar 选项) -> 系统属性(启动脚本)

就问题(似乎是 AEM 认证问题)而言,他们所问的内容不清楚。 Helpx 文章由社区贡献,上下文可能有所不同。 Sling 文档 link(根据 this link,AEM 中的启动板版本似乎是旧版本,而不是 2.4.0)。需要请Adobe确认:).

有两篇相互矛盾的 Adob​​e 文章说的完全不同

第 1 条:(假设较新)

Starting CQ with a specific run mode If you have defined configurations for multiple run modes then you need to define which is to be used upon startup. There are several methods for specifying which run mode to use; the order of resolution is:

sling.properties file
-r option
system properties (-D)
Filename detection

From this Reference: Configure Run Modes - the answer is C

第 2 条:

Behavior when run modes are specified more than one way The run mode specified in the naming of the jar file takes precedence. If run modes are not specified in the naming of the jar file, the values in the sling.properties file are used. If run modes are not specified in either the naming of the jar file or the sling.properties file, the system property (or JVM argument) is used.

From this Reference: Configure Run Modes - the answer is B

然而,根据我的经验和排除法,我会选择答案 B。