secrets.properties文件,里面是类似于key-value形式的数据
test=1d9ae43c7f0efa1261174ba82840bb0f
转换成对应的xml文件:properties.xml
java读取
InputStream input1 = BasicAuthUtil.class.getClassLoader().getResourceAsStream("secrets.properties");//InputStream input2 = BasicAuthUtil.class.getResourceAsStream("/ipConfig.properties")//InputStream input3 = new FileInputStream("D:\\second\\src\\main\\resources\\secrets.properties");//InputStream input4 = new FileInputStream("/main/resources/properties.xml");;
上面的前两种方式都是通过反射方式来获取文件的,第一种是不需要考虑路径的问题,第二种是需要加上“/”;后面第三种是根据绝对路径来读取;第四种是读取的xml文件。