测试环境-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.youkuaiyun.com/linuxarmsummary/article/details/79459719)