Springboot Freemarker配置全局變量配置類

package com.xhd.read.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Slf4j
@Configuration
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FreeMarkerConfig {
    @Autowired
    private freemarker.template.Configuration configuration;

    @Value("${system.ctx}")
    private String ctx;

    @Value("${system.spath}")
    private String spath;



    @PostConstruct
    public void setConfigure() throws Exception {

        configuration.setSharedVariable("CPATH", ctx);
        configuration.setSharedVariable("SPATH", spath);

    }

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章