測試環境-velocity模闆生成靜态頁提示"org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource "未找到資源。
/**
* 擷取模版
*/
// 擷取配置,取生成訂單快照和商品快照本地的根路徑
PropertiesLoader pl = new PropertiesLoader("/config/config.properties");
String rootPath = pl.getProperty("ROOT_HTML");
String viewPage = rootPath + File.separator + "template";
/**
* 定義模版參數
*/
Properties p = new Properties();
// 指定模闆的加載位置
p.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, viewPage);
// 指定輸入編碼
p.setProperty(VelocityEngine.INPUT_ENCODING, "UTF-8");
// 指定輸出編碼
p.setProperty(VelocityEngine.OUTPUT_ENCODING, "UTF-8");
// 設定日志資訊
p.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogChute");
// 初始化模闆引擎
Velocity.init(p);
// 擷取VelocityContext
VelocityContext context = new VelocityContext();
Template tpl = Velocity.getTemplate("test.vm");
資料來源(https://blog.csdn.net/linuxarmsummary/article/details/79459719)