DIFF.BLOG
New
Following
Discover
Jobs
More
Suggest a blog
Upvotes plugin
Report bug
Contact
About
Sign up  
xml和properties的读写
1
·
mirsery
·
July 14, 2022, 2:34 p.m.
Summary
环境路径问题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...
Read full post on mirsery.github.io →
Submit
AUTHOR
RECENT POSTS FROM THE AUTHOR