【问题标题】:Integrating Apache Shiro on Play framework 2.1在 Play 框架 2.1 上集成 Apache Shiro
【发布时间】:2013-04-10 12:35:15
【问题描述】:

我正在尝试将 Apache Shiro 集成到 Play 框架 2.1 我正在使用一个支持播放框架 2.0 的开源项目 (https://github.com/wsargent/play-shiro)

我尝试将此应用程序从 play 2.0 迁移到 2.1,但在编译项目时我不断收到这些错误...

有谁知道如何处理这个错误?

[play-shiro] $ compile
[info] Updating {file:/Users/shai/Documents/Projects/opensource/play-shiro/}play-shiro...
[info] Done updating.                                                        
[info] Compiling 13 Scala sources and 1 Java source to /Users/shai/Documents/Projects/opensource/play-shiro/target/scala-2.10/classes...
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/login.scala.html:0: not found: type Flash
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/login.scala.html:1: not found: type Flash
[error] @(form: Form[(String,String)])(implicit flash: Flash)
[error]                                               ^
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/controllers/Login.scala:36: type mismatch;
[error]  found   : play.api.data.Form[(String, String)]
[error]  required: play.data.Form[(String, String)]
[error]     Ok(html.login(loginForm))
[error]                   ^
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/controllers/Login.scala:44: type mismatch;
[error]  found   : play.api.data.Form[(String, String)]
[error]  required: play.data.Form[(String, String)]
[error]       formWithErrors => { BadRequest(html.login(formWithErrors)) },
[error]                                                 ^
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/register.scala.html:0: not found: type Flash
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/register.scala.html:1: not found: type Flash
[error] @(form: Form[(String,String)])(implicit flash: Flash)
[error]                                               ^
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/controllers/Register.scala:30: type mismatch;
[error]  found   : play.api.data.Form[(String, String)]
[error]  required: play.data.Form[(String, String)]
[error]     Ok(html.register(registerForm))
[error]                      ^
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/controllers/Register.scala:37: type mismatch;
[error]  found   : play.api.data.Form[(String, String)]
[error]  required: play.data.Form[(String, String)]
[error]           BadRequest(html.login(formWithErrors))
[error]                                 ^
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/login.scala.html:19: value map is not a member of play.data.validation.ValidationError
[error]             @form.globalError.map { error =>
[error]                               ^
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/login.scala.html:53: not found: type Flash
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/login.scala.html:55: not found: type Flash
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/register.scala.html:18: value map is not a member of play.data.validation.ValidationError
[error]   @form.globalError.map { error =>
[error]                     ^
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/register.scala.html:51: not found: type Flash
[error] /Users/shai/Documents/Projects/opensource/play-shiro/app/views/register.scala.html:53: not found: type Flash
[error] 14 errors found
[error] (compile:compile) Compilation failed
[error] Total time: 3 s, completed Apr 17, 2013 7:00:42 PM
[play-shiro] $ 

【问题讨论】:

    标签: apache frameworks playframework-2.1 shiro


    【解决方案1】:

    我已将代码升级到 2.1,但请考虑改用 Play Authenticate 或 SecureSocial。此代码从未打算达到生产质量。

    【讨论】:

    • 我正在使用您的项目作为 Play 与 Shiro 集成的基础(用于生产,是的 :))并感谢您将其开源。如果有什么值得的,我会提交一个拉取请求。
    • Shiro 更适合我们的需求,因为它提供了基于角色的细粒度管理,并且与框架无关,这对我们的设置很有好处。
    • 嘿@WillSargent 你的评论还有效吗?我正在考虑使用 shiro 并且可能基于你的工作,所以我想知道我是否应该,或者仍然回退到其他库,如 SecureSocial (这可能是矫枉过正)。 NVM ......这是一个 RTFM ;-)
    【解决方案2】:

    从 Play 升级后! 2.0 玩! 2.1,你有没有运行过以下命令?

    play clean
    play clean-files
    play compile
    

    这通常是导致这些编译问题的原因。

    如果问题仍然存在,请查看migration guide 以检查您是否确实遵循了所有必需的步骤。

    【讨论】:

      猜你喜欢
      • 2015-05-13
      • 2014-04-07
      • 2012-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-11
      • 2013-04-25
      相关资源
      最近更新 更多