xml和properties的读写

1 · mirsery · July 14, 2022, 2:34 p.m.
环境路径问题xml文件的载入properties文件载入xml的序列化properties序列化环境路径问题SpringBoot中我们可以利用ClassPathResource类,利用相对路径载入classPath路径下的文件配置。xml文件的载入/* * 读入xml文件并序列化成javaBean */ @Bean public DeviceList getDevice() throws IOException, JAXBException { String fileName = "device.xml"; File file = new File(fileName); InputStream inputStream = null; if (!file.exists()) { inputStream = new ClassPathResource("device.xml").getInputStream(); } else { inputStream = Fil...