本文共 252 字,大约阅读时间需要 1 分钟。
使用该注解的前提是配置文件上必须要有这些属性才行
假设项目中的配置文件内容是这样的
user.name=大抱儿二抱和三抱
标记在属性上
public class User { @Value("${user.name}") private String name;}
标记在方法的参数中
public class User { public User(@Value("user.name") String name) { System.out.println(name); }}
转载地址:http://hvhws.baihongyu.com/