我在 Liferay 7.0 中的什么地方放置与博客相关的邮件通知模板?

Where do I place my templates for Blog-related mail notifications in Liferay 7.0?

documentation 声明我可以配置 liferay 服务器以使用我自己的电子邮件模板。具体来说,如果我将这些属性添加到 $CATALINA_BASE/conf/liferay 中的 portal-ext-env.properties:

    blogs.email.entry.added.enabled=true
    blogs.email.entry.added.subject=${resource:com/liferay/portlet/blogs/dependencies/email_entry_added_subject.tmpl}
    blogs.email.entry.added.body=${resource:com/liferay/portlet/blogs/dependencies/email_entry_added_body.tmpl}

Liferay 将假定 使用指定路径(com/liferay/portlet/blogs/dependencies/email_entry_added_subject.tmplcom/liferay/portlet/blogs/dependencies/email_entry_added_body.tmpl)中的模板。问题是,还不是很清楚 这些路径相对于 是什么。这些文件与 $CATALINA_BASE 相关吗?例如,上面的配置会导致 Liferay 查找 $CATALINA_BASE/com/liferay/portlet/blogs/dependencies/email_entry_added_body.tmpl 来创建电子邮件正文吗?如果不是这种情况,Liferay 在哪里查找与博客相关的电子邮件消息的模板?

经过一些挖掘,我发现您将模板放在 $CATALINA_BASE/webapps/ROOT/WEB-INF/classes 文件夹中。您在属性中引用的路径(例如 blogs.email.entry.added.body=${resource:com/liferay/portlet/blogs/dependencies/email_entry_added_body.tmpl})是 相对于上述 类 文件夹 .

所以,如果我想让 Liferay 在 ff.相对路径:org/foo/my_email_entry_added_body.tmpl,我会做两件事:

  1. 将文件放在 $CATALINA_BASE/webapps/ROOT/WEB-INF/classes/org/foo/my_email_entry_added_body.tmpl
  2. 将以下行添加到 $CATALINA_BASE/portal-ext-env.propertiesblogs.email.entry.added.body=${resource:org/foo/my_email_entry_added_body.tmpl}

我咨询了我的同事,对这是为什么有了更好的理解。 Liferay 应用程序的体系结构与 Tomcat 服务器捆绑在一起。根据 documentationWEB-INF/classes 是部署到 Tomcat 服务器的 Web 应用程序查找 类 和资源的目录:

A class loader is created for each web application that is deployed in a single Tomcat instance. All unpacked classes and resources in the /WEB-INF/classes directory of your web application, plus classes and resources in JAR files under the /WEB-INF/lib directory of your web application, are made visible to this web application, but not to other ones.

具体来说,这个文件夹是high in priorty in the web app's classpath

当您看到类似于 ${resource:path/to/foo} 的 Liferay 代码时,它正在其类路径中查找资源。该类路径中的路径之一是 WEB-INF/classes。因此,如果 path/to/foo 放在 WEB-INF/classes 中,Liferay 会在那里找到 path/to/foo