InputStream.getResourceAsStream() giving null pointer exception

后端 未结 6 1371
广开言路
广开言路 2020-12-11 19:08

The line persistenceProperties.load(is); is throwing a nullpointerexception in the following method. How can I resolve this error?

6条回答
  •  [愿得一人]
    2020-12-11 19:45

    Your IDE works with two different scopes:

    • production scope: src/main/java + src/main/resources folders and
    • test scope: src/test/java + src/test/resources

    Seems you are trying to execute you program from production scope, while persistence.properties file is placed into test scope.

    How to fix:

    • Place your test into src/test/java or
    • Move persistence.properties into src/main/resources

提交回复
热议问题