@Value static静态变量注入
把@Value 注入 到static静态变量 中以方便调用, 代码如下
package com.wenhe.blogcommon.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
/**
* @author wenhe
* @date 5/10/2022 下午 9:06
*/
@Component
public class SystemConfig {
public static String imagePath ;
public static String uploadPrefix ;
public static String uploadRealDir ;
@Value("${mfile.imagepath}")
public void setImagePath(String imagePath) {
SystemConfig.imagePath = imagePath;
}
@Value("${mfile.prefix}")
public void setUploadPrefix(String uploadPrefix) {
SystemConfig.uploadPrefix = uploadPrefix;
}
@Value("${spring.servlet.multipart.location}")
public void setUploadRealDir(String uploadRealDir) {
SystemConfig.uploadRealDir = uploadRealDir;
}
}
(。・v・。)
喜欢这篇文章吗?欢迎分享到你的微博、QQ群,并关注我们的微博,谢谢支持。