Spring 裏面使用velocity作文郵件模板,但是發送時提示找不到文件資源。原因:要對創建的velocityengine 進行設置。
方法如下:
velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER,"classpath" );
velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
velocityEngine.init();
在資源路徑裏面設置:
templates/xxxxx.vm