第一步:修改Spring配置文件
在spring配置文件添加如下标签
第二步:使用
@Component
public class DruidUtil{
@Value("${url}")
private String url;
@Value("${username}")
private String username;
@Value("${password}")
private String password;
}
这样就可以拿到properties中的值了