Search code examples
javaintellij-ideajunitclassloadersubdirectory

Intellij resource subfolder not included in classpath


I am trying to load a resource using ClassLoader.getResourceAsStream in a JUnit test in Intellij, and it is not found if the resource is in a subfolder. It is found fine in the root of the test resources folder. I am using the correct replace-dots-with-slash notation.-

This is different from the question asked here because I realized I had added a slash in the beginning of the resource path.


Solution

  • The resource path must not start with a slash.