Spring Boot access static resources missing scr/main/resources

前端 未结 8 498
别那么骄傲
别那么骄傲 2020-12-04 16:39

I am working on a Spring Boot application. I need to parse an XML file (countries.xml) on start. The problem is that I do not understand where to put it so that I could acce

8条回答
  •  渐次进展
    2020-12-04 16:43

    You need to use following construction

    InputStream in = getClass().getResourceAsStream("/yourFile");
    

    Please note that you have to add this slash before your file name.

提交回复
热议问题