【问题标题】:Load module configuration file from FS magnolia 5.7.9从 FS magnolia 5.7.9 加载模块配置文件
【发布时间】:2021-03-05 08:27:22
【问题描述】:

我需要了解在什么条件下从文件系统 (FS) 加载模块配置文件。具体我想知道为什么配置中没有加载config.yaml文件? 这是我的src/main/resources/<magnolia-module-name>/config.yaml根据@​​987654321@和here描述的文件模块结构。

'config':
  'gitRepoDirectory': '/Users/asusti/jGit/'
  'tempVersionDirectory': '/Users/asusti/temp/'
  'excludes':
    'green': 'green'
    'red': 'red'

我从模块配置中将此配置文件导出为 yaml 并将其复制到上述文件位置。

根据示例here,我也尝试使用这样的config.yaml:

gitRepoDirectory: /Users/asusti/jGit/
excludes:
   green: green
   red: red

为了测试这一点,我从 config/modules/<magnolia-module-name> 下的配置应用程序中删除了 config content node 并重新启动了 magnolia 实例。我错过了什么?

我正在运行 magnolia 5.7.9.

更新:

按照here的建议,我将config.yaml添加到src/main/resources/mgnl-bootstrap/<magnolia-module-name>/config.modules.<magnolia-module-name>.config.yaml,内容如下。

'config':
  'gitRepoDirectory': '/Users/asusti/jGit/'
  'jcr:primaryType': 'mgnl:content'
  'excludes':
    'green': 'green'
    'red': 'red'

config文件夹和下面的属性和节点没有安装在config中。

解决方案: 对于引导,我找到了文档here 根据此文档:

All bootstrap files are only imported once!

    Webapp-based bootstrap files are imported during the first run of the webapp when the Magnolia instance gets installed.
    Module-based bootstrap files are imported during the installation of the module.

If you want to import bootstrap files on every start up of the Magnolia instance or of a module, you must use custom installation tasks which are executed by the Module version handler or Module start up classes.

【问题讨论】:

    标签: magnolia


    【解决方案1】:

    您正在混合两种东西。您可以拥有 yaml 格式的引导文件(即代码 smippets 的第一个和第三个),并且您可以在运行时从 config.yaml 文件加载模块配置(即第二个代码 sn-p 的格式)。

    对于在运行时从 yaml 文件加载模块配置的情况,您不需要删除整个模块并强制重新安装,只需将 config.yaml 文件放置在指定位置后删除 jcr 中的 config 子节点地点。然后您将不会看到 jcr 中的配置,但可以通过模块类中的代码查询它或在定义应用程序中看到它。

    由于 JCR 配置会覆盖来自文件的配置,只要您在 JCR 中的 module 节点中有 config 节点,它将覆盖来自 FS 的属性值。

    【讨论】:

    • 谢谢@Jan 在 magnolia 5.7.9 版中模块 config.yaml 的正确位置是什么?根据这个documentation.magnolia-cms.com/display/DOCS57/… 的唯一方法是我猜想使用代码 sn-p 3 进行引导。我一定遗漏了一些东西,因为我的模块配置文件没有从 FS 加载。我可以断言,因为我从代码中查询它,如果我在 JCR 中输入配置,代码可以正常工作。
    • 正确的位置是这样在编译的 jar 文件中它最终在 /<module-name>/module.yaml 但你是对的,你不能在 5.7 中使用它来设置模块类的属性并且仍然需要依靠引导它到 JCR(你的第三个 sn-p)
    【解决方案2】:

    我认为这是因为您检查了错误的文档。请参考https://documentation.magnolia-cms.com/display/DOCS57/的5.7文档

    如果我没记错的话,该功能是从 6.1 版本开始实现的。

    您要查找的页面如下:https://documentation.magnolia-cms.com/display/DOCS57/Module+configuration#Moduleconfiguration-ConfiguringinJCRvsYAML

    注意那里的 bean 定义。

    【讨论】:

    • config 文件夹及其下方的属性和节点未安装。请参阅上面的更新@Ducaz035
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-30
    相关资源
    最近更新 更多