hdy
2024-06-07 4a53ae7900954ef581b45a9c742f01ded1a66db5
提交 | 用户 | 时间
e57a89 1 package com.jcdm.generator.util;
2
3 import java.util.Properties;
4 import org.apache.velocity.app.Velocity;
5 import com.jcdm.common.constant.Constants;
6
7 /**
8  * VelocityEngine工厂
9  * 
10  * @author jc
11  */
12 public class VelocityInitializer
13 {
14     /**
15      * 初始化vm方法
16      */
17     public static void initVelocity()
18     {
19         Properties p = new Properties();
20         try
21         {
22             // 加载classpath目录下的vm文件
23             p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
24             // 定义字符集
25             p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8);
26             // 初始化Velocity引擎,指定配置Properties
27             Velocity.init(p);
28         }
29         catch (Exception e)
30         {
31             throw new RuntimeException(e);
32         }
33     }
34 }