2

I'd like to store a database schema in its own file, and have my Scala code retrieve it (and execute it via JDBC).

It seems to me that sbt wants me to store the file as: src/main/resources/packagename/my.sql. Putting it there, I see it's in the jar - but I can't seem to access it from Scala.

Specifically, getClass().getResource("my.sql") returns a null pointer, and so does any other form I can think of.

How should I load the file? Or is there a better way to do it?

4

2 回答 2

1

我有一个几乎相同的问题。唯一的区别是我的文件在src/main/resources(没有任何包)。这对我有用。

val is:InputStream = Github.getClass().getResourceAsStream( "/repo.json" );
于 2011-01-31T08:31:18.613 回答
-1

为什么不生成一个文件,并将其存储为“my.sql”,然后搜索它,它出现在文件系统中的哪个位置?

于 2011-01-30T22:08:11.833 回答