package com.jiayue.insu.incloud.config;

import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * 模板  配置类
 *
 * @author yh
 * @version 1.0
 * @since 2022/5/22 11:29
 */
@Configuration
public class VelocityConfig {


    @Bean
    public VelocityEngine velocityEngine() {



        VelocityEngine ve = new VelocityEngine();
        Properties properties = new Properties();
        //    String vmsPath = BaseService.class.getClassLoader().getResource("vms").getPath();
        //设置velocity资源加载方式为file
        properties.setProperty("resource.loader", "file");
        //设置velocity资源加载方式为file时的处理类
        properties
                .setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
        properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "");
        properties.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
        properties.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
        properties.setProperty(Velocity.OUTPUT_ENCODING, "UTF-8");
        ve.init(properties);
        return ve;
    }
}
