中国算力平台算力登记系统2.0
yanzhaofeige
2024-09-30 f21d302f4ccb816ca2d411544b5ff8bd4f9d4cac
commit | author | age
43dc29 1 package com.odcc.cpzidc.generator.util;
Y 2
3 import java.util.Properties;
4 import org.apache.velocity.app.Velocity;
5 import com.odcc.cpzidc.common.constant.Constants;
6
7 /**
8  * VelocityEngine工厂
9  * 
10  * @author ruoyi
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 }