六、SpringBoot配置@ConfigurationProperties与@Value区别

1.@Value的使用

三种用法

1 // ${key} 从环境变量、配置文件中取值
2 @Value("${person.last-name}")
3 private String lastName;
4 // #{Spel} Spring支持的表达式
5 @Value("#{11*2}")
6 private Integer age;
7 // 字面量
8 @Value("true")
9 private Boolean boss;

运行结果

猜你喜欢

转载自www.cnblogs.com/jtfr/p/10500487.html