方式一:
//创建Properties对象
Properties prop = new Properties();
//读取classPath中的properties文件
prop.load(ConsumerController.class.getClassLoader().getResourceAsStream("bean.properties"));
//根据键取出值
String className = prop.getProperty("test");//读取bean.properties里面,test的值
==================================================================
方式二:
使用工具类,将属性@Value("server.port)类似赋值,类加@Component以服务注入ÿ