【发布时间】:2021-03-03 19:40:09
【问题描述】:
在文档中用于 magnolia 模块配置的 example 中,我不确定为什么 FooBar 类的 private boolean colorsEnabled; 不在 YAML 配置中。模块配置从哪里获取colorsEnabled 属性?
maxSize: 25
welcomeMessage: Hello world
fooBar:
colors: [red, green, blue]
当我以编程方式检索List<String> list = fooBar.getColors(); 时,我得到null 的列表。
我正在运行 Magnolia 5.7.9。
更新:
我的模块类的完成方式与documentation 和上述示例中描述的方式相同。
public class XxxVersioning implements ModuleLifecycle {
private Excludes excludes;
public Excludes getExcludes() {
return excludes;
}
public void setExcludes(Excludes excludes) {
this.excludes = excludes;
}
public class Excludes {
private String red;
private String green;
public String getRed() {
return red;
}
public void setRed(String red) {
this.red = red;
}
public String getGreen() {
return green;
}
public void setGreen(String green) {
this.green = green;
}
}
我有一个以编程方式查询字符串值是否在列表中的类。该列表似乎是null。
/**
* Find if template name for the component in the module exception list
* @param String templateName
* @return Boolean true if templateName in the module exception-list
*/
public Boolean isComponentException(String templateName) {
// get the (singleton) instance of the module
// On the module class instance call the getter methods of the module bean properties.
XxxVersioning moduleInstance = xxxVersionProvider.get();
// access the modules RenderingExcludes bean
XxxVersioning.Excludes excludes = moduleInstance.getExcludes();
String green = excludes.getGreen();
return true;
}
解决方案: 对于引导,我找到了文档 [这里][5] 根据此文档
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.
【问题讨论】:
-
你能把你的模块类粘贴到这里吗?例如,您是否有匹配 colorsEnabled 的 getter 和 setter?
标签: magnolia