gpt4 book ai didi

scala - Lift 和 Lifty 入门

转载 作者:行者123 更新时间:2023-12-03 17:55:46 24 4
gpt4 key购买 nike

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

问题是 Lifty 和 sbt (还有Lift!)自这本书出版以来一直在进步。我安装了 sbt来自 Ubuntu 的 Typesafe 存储库。现在我被困在尝试安装 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 来安装 Lifty 0.7.7.但是如果我这样做
> 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

最佳答案

我不想打破它给你,但升力已经不见了。在撰写本文时,sbt 的稳定值为 0.13.0。看着 sbt community repo ,唯一发布的版本是 1.7.4 for sbt 0.11.2。
official website说:

The Lift Cookbook is the most up-to-date resource to learn how to use Lift.


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

Problem

You want want to create a Lift web project from scratch without using the ZIP files provided on the official Lift website.

Solution

You will need to configure SBT and the Lift project yourself. Luckily, only five small files are needed.First, create an SBT plugin file at project/plugins.sbt (all filenames are given relative to the project root directory):

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

This file tells SBT that you will be using the xsbt-web-plugin.

Next, create an SBT build file, build.sbt...


不幸的是,xsbt-web-plugin 0.3.0 适用于 sbt 0.12。所以你要么使用 sbt 0.12,要么稍微修改指令。最新 xsbt-web-plugin对于 sbt 0.13 是 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/使用浏览器:

Welcome, you now have a working Lift installation

关于scala - Lift 和 Lifty 入门,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11741812/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com