Access file under test resources through test application properties

时间:2018-08-22 13:51:13

标签: spring spring-properties

I have two files under the following folder hierarchy src/test/resources/folderA/fileA and src/test/resources/folderA/fileB. I have a reference to these files from the application.properties under test resources (src/test/resources/application.properties). The reference is the following:

propertyA=classpath:/folderA/fileB
propertyA=classpath:/folderA/fileA

Unfortunately this is apparently not working. It breaks with the following exception:

Caused by: java.io.FileNotFoundException: classpath:/folderA/fileA (No such file or directory)

I have tried also the following:

propertyA=classpath:folderA/fileB
propertyA=/folderA/fileB
propertyA=folderA/fileB 

and they are also not working. So what is the appropriate way to refer a resource file from test application properties in order to be property loaded?

0 个答案:

没有答案