在多个版本中加载资源时出现问题

时间:2018-10-19 14:11:40

标签: scala sbt

我是学习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

0 个答案:

没有答案