You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Alfresco模块部署中仅覆盖单个文件?

How to Override a Single Web Script File in Alfresco SDK 2.0.0 (Share 5.1.e)

Absolutely! You don’t need to replace an entire package to override just one web script file. There are two straightforward ways to achieve this with your current module setup:

Method 1: Keep Only the Target File in Your Source Directory

Your existing module configuration maps source package paths to target Alfresco package paths—but it only overwrites files that exist in your source directory. OOTB files you don’t include in your source will remain untouched.

Here’s what to do:

  1. In your project’s site-webscripts/com/some/components/preview folder, delete all files except web-preview.get.html.ftl.
  2. Keep your module configuration exactly as it is:
<module>
  <id>Highlight Query Text</id>
  <auto-deploy>true</auto-deploy>
  <description>Highlight text in web previewer</description>
  <version>1.0</version>
  <customizations>
    <customization>
      <targetPackageRoot>org.alfresco.components.preview</targetPackageRoot>
      <sourcePackageRoot>com.some.components.preview</sourcePackageRoot>
    </customization>
  </customizations>
</module>

When deployed, only the web-preview.get.html.ftl file will be replaced; all other OOTB preview component files stay intact.

Method 2: Explicitly Target a Single File with <files>

For more precision (especially if you have other files in your source package that you don’t want to override), you can use the <files> element to specify exactly which file to replace. Update your module configuration like this:

<module>
  <id>Highlight Query Text</id>
  <auto-deploy>true</auto-deploy>
  <description>Highlight text in web previewer</description>
  <version>1.0</version>
  <customizations>
    <customization>
      <targetPackageRoot>org.alfresco.components.preview</targetPackageRoot>
      <sourcePackageRoot>com.some.components.preview</sourcePackageRoot>
      <files>
        <file>
          <targetPath>web-preview.get.html.ftl</targetPath>
          <sourcePath>web-preview.get.html.ftl</sourcePath>
        </file>
      </files>
    </customization>
  </customizations>
</module>

This tells Alfresco to only replace the specific file listed, ignoring any other files in your source package.

Quick Notes

  • Double-check the file path and name: Web script filenames are case-sensitive and follow a strict format (e.g., .get.html.ftl for GET-request HTML templates). A typo here will prevent the override from working.
  • If you’re in development mode, you may need to restart your Alfresco server or refresh the web script container (via the web script console) to see changes take effect.

内容的提问来源于stack exchange,提问作者Vikash Patel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:38:42