How should I discover test-resource files in a Maven-managed Java project?

后端 未结 4 1139
北恋
北恋 2021-02-13 21:06

I have a project that uses the normal Maven structure, e.g.

module
\\ src
  \\ main
    - java
    - resources
  \\ test
    - java
    - resources
4条回答
  •  野的像风
    2021-02-13 21:48

    1. put desired resource into /src/test/resources/lipsum.pdf
    2. find it's full path using

      String fileName = ClassLoader.getSystemResource("lipsum.pdf").getFile();

提交回复
热议问题