这里绝对是 Scala 初学者。我在 macOS X 中安装了 scala 2.12.1。
我正在尝试设置来自 here 的示例 computer-database
Play-Slick 示例
一旦我 cd
进入计算机数据库,我运行 sbt run
,它导致了这个错误:
error: not found: value PlayKeys "PlayKeys.playOmnidoc := false"
这些是文件夹根目录下 build.sbt
的默认内容:
name := "computer-database-sample"
PlayKeys.playOmnidoc := false
我尝试将以下行添加到 build.sbt
以在 PlayKeys 调用之前显式导入 play-slick:
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "2.0.0",
"com.typesafe.play" %% "play-slick" % "0.6.0.1",
"com.typesafe.slick" %% "slick-extensions" % "3.1.0"
)
但我仍然遇到同样的错误。
我错过了什么吗?这是应该如何设置 Scala 项目吗?
最佳答案
停止你正在做的任何修改,恢复它们(你需要从 repo 获得干净的版本)。
执行以下操作(不是最快的 root,但可以让您边走边探索其他方面的事情):
1) 转到 repo 根目录。
2) 类型:sbt
- 如果它不起作用,请先安装 sbt
3) 在第 2 点成功后,您应该会看到以下内容:
[pdolega@maracuja play-slick]$ sbt
[info] Loading project definition from /home/pdolega/projects/slick/play-slick/project
[info] Compiling 1 Scala source to /home/pdolega/projects/slick/play-slick/project/target/scala-2.10/sbt-0.13/classes...
Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
Missing bintray credentials /home/pdolega/.bintray/.credentials. Some bintray features depend on this.
[info] Set current project to play-slick-root (in build file:/home/pdolega/projects/slick/play-slick/)
>
4) 类型:项目
。你会看到所有的 sbt
子项目:
> projects
[info] In file:/home/pdolega/projects/slick/play-slick/
[info] basic-sample
[info] computer-database-sample
[info] docs
[info] iteratee-sample
[info] play-slick
[info] play-slick-evolutions
[info] * play-slick-root
[info] samples
>
4) 键入project computer-database-sample
<- 这将使您想要的子项目处于事件状态。
> project computer-database-sample
[info] Set current project to computer-database-sample (in build file:/home/pdolega/projects/slick/play-slick/)
[computer-database-sample] $
5) 现在您可以为安装执行 test
,它将运行编译和之后的所有测试。或者您可以键入 run
来启动这个示例 Play 应用程序。
[computer-database-sample] $ run
[warn] Credentials file /home/pdolega/.bintray/.credentials does not exist
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
关于scala:运行一个 play-slick 示例导致导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41625862/