【问题标题】:using security helpers does not compile : play framework 2.3.x使用安全助手无法编译:play framework 2.3.x
【发布时间】:2014-12-15 10:02:04
【问题描述】:

我正在尝试在控制器中使用安全助手,如 Security.scala 的源代码所示

https://github.com/playframework/playframework/blob/2.3.x/framework/src/play/src/main/scala/play/api/mvc/Security.scala#L31

我的代码看起来像

import play.mvc.Security.Authenticated

Application extends Controller {
  ..... some other Actions
  def isAuthenticated(f: => String => Request[AnyContent] => Result) = {
      Authenticated { user =>
          Action(request => f(user)(request))
        }
    }
}

但是,我收到以下编译错误

[info] Compiling 1 Scala source to /home/venki/play/lrs/target/scala-2.11/classes...
[error] /home/venki/play/lrs/app/controllers/Application.scala:119: object play.mvc.Security.Authenticated is not a value
[error]       Authenticated { user =>
[error]       ^
[error] one error found
[error] (compile:compile) Compilation failed

我无法理解错误。从源代码中我可以看到 Security 对象包含两个名为 Authenticated 的重载方法。我已经完全复制粘贴了作为示例用法给出的代码,但它仍然不起作用。非常感谢任何帮助

【问题讨论】:

    标签: scala playframework-2.3


    【解决方案1】:

    您在 github 上引用的安全类型位于 play.api.mvc 包中,但您是从 play.mvc 导入的。 play.mvc 是为 Java 保留的,而不是为 Scala 保留的,see here 以获取更多信息。

    【讨论】:

    • 伙计..你是我的救星。你应该得到一枚奖牌
    猜你喜欢
    • 2015-06-21
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    相关资源
    最近更新 更多