我是学习scala / sbt的初学者。对于多个构建项目,例如以下示例:
|-- Bar
| |-- build.sbt
| +-- src
| |-- main
| | |-- java
| | |-- resources
| | | +-- config
| | | +-- app.properties
| | +-- scala
| | +-- Bar.scala
| +-- test
| |-- java
| +-- resources
|-- Foo
| |-- build.sbt
| +-- src
| |-- main
| | |-- java
| | |-- resources
| | +-- scala
| | +-- Foo.scala
| +-- test
| |-- java
| +-- resources
|-- build.sbt
|-- project
| |-- Build.scala
在Bar.scala
中,我尝试从资源中加载文件,但找不到它:
val resourcesPath = getClass.getResource("config/app.properties")
println(resourcesPath.getPath)
>> Exception in thread "main" java.lang.NullPointerException