Springboot 工具类静态注入

用springboot搭了一个项目,里面要用到一个DictUtils,因为要用到DictMapper,在百度找了一些方法,最后用下面的方法能成功获取到DictMapper

@Component
public class DictUtils {

    @Resource
    private DictMapper dictMapper1;

    private static DictMapper dictMapper;

    @PostConstruct
    public void init() {
        this.dictMapper = dictMapper1;
    }
}

 

posted @ 2018-04-08 17:56  双子座的皮卡丘  阅读(223)  评论(0编辑  收藏  举报