spring中加载属性文件:在springmvc.xml中配置,
<context:property-placeholder location="classpath:xxx.properties" />
类中获取使用注解获取:
@Value(“${IMAGE_SERVER_URL}”)
private String IMAGE_SERVER_URL;
通用的方式:getResourceAsStream()方法结合Properties对象
InputStream inputStream=this.getClass().getResourceAsStream("/xx/xxx.properties");
Properties properties=new Properties();
properties.load(inputStream);
String url=properties.getProperty("xxx");
关于getResourceAsStream的使用看我的这篇文章:[https://mp.csdn.net/mdeditor/81676142]