在 AEM 6.5 中,如果对模板进行了更改并重新部署,但更改未应用,请按照以下步骤检查。
确认是否在模板项目的配置中启用了自动部署功能。如果不是,请手动部署模板更改。
如果启用了自动部署功能,确保已将模板打成一个 jar 文件并将其存储在 AEM 实例的 OSGi 容器中。jar 文件应为“内容包”或“模板”类型。示例代码如下:
package com.adobe.aem.guides.wknd.core.templates;
import org.slf4j.Logger; import org.slf4j.LoggerFactory;
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference;
import com.day.cq.commons.jcr.JcrConstants; import com.day.cq.wcm.api.Page; import com.day.cq.wcm.api.PageManager; import com.day.cq.wcm.api.Template; import com.day.cq.wcm.api.TemplateManager; import com.day.cq.wcm.api.WCMException;
@Component( immediate = true, service = Template.class, property = { Constants.SERVICE_RANKING + ":Integer=-20", JcrConstants.JCR_PRIMARYTYPE + "=cq:Template", "sling.servlet.resourceTypes=" + "wknd/components/templates/content-page", "sling.servlet.selectors=" + "content-page" } ) public class ContentPageTemplate implements Template {
private static final Logger LOGGER = LoggerFactory.getLogger(ContentPageTemplate.class);
@Reference
private TemplateManager templateManager;
@Reference
private PageManager pageManager;
@Override
public String getName() {
return "WKND Content Page Template";
}
@Override
public String getShortName() {
return "WKND Content Page";
}
@Override
public String getDescription() {