@Value 注入静态变量
生活随笔
收集整理的這篇文章主要介紹了
@Value 注入静态变量
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、定義配置類
@Component public class FilePathConfig {public static String httpResUrl;public static String savePath;public static String resUri;public String getHttpResUrl() {return httpResUrl;}@Value("${file.path.httpResURL}")public void setHttpResUrl(String httpResUrl) {this.httpResUrl = httpResUrl;}public String getSavePath() {return savePath;}@Value("${file.path.SAVE_PATH}")public void setSavePath(String savePath) {this.savePath = savePath;}public String getResUri() {return resUri;}@Value("${file.path.resURI}")public void setResUri(String resUri) {this.resUri = resUri;} }2、在配置文件中配置
#圖片存儲地址 file:path:httpResURL: http://127.0.0.1:18080SAVE_PATH: /data/imagesresURI: /parking_platform/?
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的@Value 注入静态变量的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第四十九期:大牛总结的MySQL锁优化,
- 下一篇: Base64 四种方式的编码和解码