工具类中静态方法用到注入对象

2020-07-17  本文已影响0人  hehehehe

package com.ecarx.ads.processstore.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * 类描述 <p>
 * @since 2020/7/6 14:31
 */
@Component
@PropertySource(value = "classpath:process-path.properties")
public class ProcessPathConfig {

    public static String imp_split_info_src;

    public static String imp_overedge_deduplicate_src;

    public static String imp_recognition_src;

    public static String imp_manbuild_src;

    public static String imp_build_service_src;

    public static Map<String, Map<String, String>> processInfoMap = null;

    @Value("#{'${imp_split_info_src}'}")
    public void setImp_split_info_src(String imp_split_info_src) {
        ProcessPathConfig.imp_split_info_src = imp_split_info_src;
    }

    @Value("#{'${imp_overedge_deduplicate_src}'}")
    public void setImp_overedge_deduplicate_src(String imp_overedge_deduplicate_src) {
        ProcessPathConfig.imp_overedge_deduplicate_src = imp_overedge_deduplicate_src;
    }

    @Value("#{'${imp_recognition_src}'}")
    public void setImp_recognition_src(String imp_recognition_src) {
        ProcessPathConfig.imp_recognition_src = imp_recognition_src;
    }

    @Value("#{'${imp_manbuild_src}'}")
    public void setImp_manbuild_src(String imp_manbuild_src) {
        ProcessPathConfig.imp_manbuild_src = imp_manbuild_src;
    }

    @Value("#{'${imp_build_service_src}'}")
    public void setImp_build_service_src(String imp_build_service_src) {
        ProcessPathConfig.imp_build_service_src = imp_build_service_src;
    }
    @PostConstruct
    void init(){
        ProcessPathConfig.processInfoMap =  new HashMap<String, Map<String, String>>() {{
            put("imp_split_info", new HashMap<String, String>() {{
                put("destPath", imp_split_info_src);
            }});
            put("imp_overedge_deduplicate", new HashMap<String, String>() {{
                put("destPath", imp_overedge_deduplicate_src);
            }});
            put("imp_recognition", new HashMap<String, String>() {{
                put("destPath", imp_recognition_src);
            }});
            put("imp_manbuild", new HashMap<String, String>() {{
                put("destPath", imp_manbuild_src);
            }});
            put("imp_build_service", new HashMap<String, String>() {{
                put("destPath", imp_build_service_src);
            }});
        }};
    }

}

上一篇下一篇

猜你喜欢

热点阅读