cloud-modules-gen/src/main/java/com/muyu/gen/util/VelocityInitializer.java

31 lines
836 B
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.muyu.gen.util;
import com.muyu.common.core.constant.Constants;
import org.apache.velocity.app.Velocity;
import java.util.Properties;
/**
* VelocityEngine工厂
*
* @author muyu
*/
public class VelocityInitializer {
/**
* 初始化vm方法
*/
public static void initVelocity () {
Properties p = new Properties();
try {
// 加载classpath目录下的vm文件
p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
// 定义字符集
p.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8);
// 初始化Velocity引擎指定配置Properties
Velocity.init(p);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}