如何在Alfresco模块部署中仅覆盖单个文件?
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:
- In your project’s
site-webscripts/com/some/components/previewfolder, delete all files exceptweb-preview.get.html.ftl. - 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.ftlfor 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

