【问题标题】:Getting started with Lift and LiftyLift 和 Lifty 入门
【发布时间】:2012-07-29 07:40:49
【问题描述】:

我正在尝试开始使用 Lift 框架,阅读 Lift in Action。我想跟随示例,但我立即偶然发现了安装 Lift 的问题。我知道有多种方法可以轻松开始使用 Lift,但我想像本书一样使用 Lifty,以便能够遵循它。

问题在于 Lifty 和 sbt(还有 Lift!)自本书出版以来都在向前发展。我从 Ubuntu 的 Typesafe 存储库中安装了 sbt。现在我一直在尝试安装 Lifty。

Lifty documentationthis answer on SO 之后 - 由于Lifty 尚未发布sbt 0.11.3 的二进制文件 - 我认为我应该将以下内容放入~/.sbt/plugins/build.sbt

resolvers += Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)

addSbtPlugin("org.lifty" % "lifty" % "1.7.4")

libraryDependencies +=
  Defaults.sbtPluginExtra(
    "org.lifty" % "lifty" % "1.7.4",
    "0.11.2",
    "2.9.1"
  )

后者是告诉sbt 使用 sbt 0.11.2 的 Lifty 插件。

现在sbt 似乎可以下载Lifty 并正确启动,但我没有lifty 命令。所以当我这样做时

lifty learn lift https://raw.github.com/Lifty/lifty/master/lifty-recipe/lifty.json

sbt 抱怨:

[error] Not a valid key: lifty (similar: history)
[error] lifty learn lift https://raw.github.com/Lifty/lifty/master/lifty-recipe/lifty.json
[error]      ^

我应该如何安装 Lifty?请注意,我是 Scala、sbt 和 Lift 的新手。

编辑

我设法通过降级到 sbt 0.7.7 来安装 Lifty。但是如果我这样做了

> lift create project-blank
> reload
> update

我得到了错误

[error] sbt.ResolveException: unresolved dependency: net.liftweb#lift-webkit_2.9.1;2.3-RC3: not found
[error] unresolved dependency: org.scala-tools.testing#specs_2.9.1;1.6.6: not found
[info] == update ==
[error] Error running update: sbt.ResolveException: unresolved dependency: net.liftweb#lift-webkit_2.9.1;2.3-RC3: not found
[error] unresolved dependency: org.scala-tools.testing#specs_2.9.1;1.6.6: not found

【问题讨论】:

  • 我在 LiA 工作。我很难让示例使用 SBT 10+,使用 SBT 0.7。
  • 谢谢。你知道我如何使用旧版本的 sbt 吗?可能同时保留从 Typesafe 存储库安装的最新版本
  • 我刚刚下载了旧的 jar,制作了某种 shell 脚本来运行它。并将其添加到$PATH。全部完成。
  • 谢谢,我试试这个方法

标签: scala lift sbt lifty


【解决方案1】:

我不想把它告诉你,但lifty 不见了。在撰写本文时,sbt 的稳定版本为 0.13.0。查看sbt community repo,唯一发布的版本是 sbt 0.11.2 的 1.7.4。

official website 说:

Lift Cookbook 是学习如何使用 Lift 的最新资源。

有一个名为Creating a Lift Project from Scratch Using SBT的部分:

问题

您想在不使用 Lift 官方网站上提供的 ZIP 文件的情况下从头开始创建一个 Lift Web 项目。

解决方案

您需要自己配置 SBT 和 Lift 项目。幸运的是,只需要五个小文件。 首先,在project/plugins.sbt创建一个SBT插件文件(所有文件名都是相对于项目根目录给出的):

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.3.0")

这个文件告诉 SBT 你将使用 xsbt-web-plugin。

接下来,创建一个 SBT 构建文件 build.sbt...

不幸的是,xsbt-web-plugin 0.3.0 适用于 sbt 0.12。所以你必须要么使用 sbt 0.12,要么稍微修改一下指令。 sbt 0.13 的最新 xsbt-web-plugin 是 0.4.2,所以在 project/plugins.sbt 中放:

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.4.2")

resolvers += Resolver.sonatypeRepo("public")

我能够按照页面上的其余说明进行操作... 最终我得到了 sbt 0.13 的所有内容,并且能够启动容器:

> container:start
[info] Compiling 1 Scala source to /foo/sbt-lift-test/target/scala-2.10/classes...
[info] jetty-8.1.7.v20120910
....
[success] Total time: 2 s, completed Sep 20, 2013 10:34:22 PM

使用浏览器打开http://localhost:8080/

欢迎,您现在已经安装了有效的电梯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-30
    • 2011-05-22
    • 2016-08-03
    • 2017-02-22
    • 2011-10-11
    相关资源
    最近更新 更多