1. 程式人生 > 其它 >Springboot 中Value 註解@Value(${})和 @Value(#{})

Springboot 中Value 註解@Value(${})和 @Value(#{})

技術標籤:spring系列javaspringspring boot

在這裡插入圖片描述


value = "/api/city/{id}"



@Value("#{}")

    其實是SpEL表示式的值,可以表示常量的值,或者獲取bean中的屬性


@Value("${}")

    用於獲取配置檔案中的屬性值,通常用於獲取寫在application.properties中的內容,例如在配置檔案中:

參考Springboot 中@Value 註解的使用及@Value(${})和 @Value(#{})的區別