Autowired annotation is not supported on static fields
@Configuration
public class ConfigUtils implements ApplicationContextAware {
private static Environment env;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
env = applicationContext.getBean(Environment.class);
}
public static String getValue(String key) {
return env.getProperty(key);
}
/**
* 图片上传地址
*
* @return
*/
public static String getImageUploadDir() {
return getValue("imageUploadDir");
}
/**
* 图片预览地址
*
* @return
*/
public static String getImageVisitPath() {
return getValue("imageVisitPath");
}
}