2014-09-19 48 views
3

我正在將Play 2.2應用程序移植到Play 2.3應用程序(Scala)中。 爲此,我將te安全社交版更改爲支持Play 2.3的主SNAPSHOT。 但在編譯時在我的播放控制檯遇到錯誤。將Play 2.2應用程序移植到2.3.2版本(Scala)時出錯

怎麼了?

[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:33: ambiguous implicit values: 
[error] both method request2lang in trait Controller of type (implicit request: play.api.mvc.RequestHeader)play.api.i18n.Lang 
[error] and value lang of type play.api.i18n.Lang 
[error] match expected type play.api.i18n.Lang 
[error]  securesocial.views.html.Registration.signUp(form, token) 
[error]            ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:44: could not find implicit value for parameter env: securesocial.core.RuntimeEnvironment[_] 
[error]  securesocial.views.html.Registration.startSignUp(form) 
[error]             ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:55: could not find implicit value for parameter env: securesocial.core.RuntimeEnvironment[_] 
[error]  securesocial.views.html.Registration.startResetPassword(form) 
[error]               ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:66: could not find implicit value for parameter env: securesocial.core.RuntimeEnvironment[_] 
[error]  securesocial.views.html.Registration.resetPasswordPage(form, token) 
[error]               ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:77: not found: type SecuredRequest 
[error] def getPasswordChangePage[A](implicit request: SecuredRequest[A], form: Form[ChangeInfo]): Html = { 
[error]            ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:78: Cannot find any HTTP Request Header here 
[error]  securesocial.views.html.passwordChange(form) 
[error]           ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:99: not found: type Identity 
[error] def getAlreadyRegisteredEmail(user: Identity)(implicit request: RequestHeader): (Option[Txt], Option[Html]) = { 
[error]          ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:100: could not find implicit value for parameter env: securesocial.core.RuntimeEnvironment[_] 
[error]  (None, Some(securesocial.views.html.mails.alreadyRegisteredEmail(user))) 
[error]                 ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:110: not found: type Identity 
[error] def getWelcomeEmail(user: Identity)(implicit request: RequestHeader): (Option[Txt], Option[Html]) = { 
[error]       ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:111: could not find implicit value for parameter env: securesocial.core.RuntimeEnvironment[_] 
[error]  (None, Some(securesocial.views.html.mails.welcomeEmail(user))) 
[error]               ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:122: too many arguments for method apply:()(implicit request: play.api.mvc.RequestHeader, implicit lang: play.api.i18n.Lang)play.twirl.api.HtmlFormat.Appendable in object unknownEmailNotice 
[error]  (None, Some(securesocial.views.html.mails.unknownEmailNotice(request))) 
[error]                ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:133: not found: type Identity 
[error] def getSendPasswordResetEmail(user: Identity, token: String)(implicit request: RequestHeader): (Option[Txt], Option[Html]) = { 
[error]          ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:134: could not find implicit value for parameter env: securesocial.core.RuntimeEnvironment[_] 
[error]  (None, Some(securesocial.views.html.mails.passwordResetEmail(user, token))) 
[error]                ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:144: not found: type Identity 
[error] def getPasswordChangedNoticeEmail(user: Identity)(implicit request: RequestHeader): (Option[Txt], Option[Html]) = { 
[error]           ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:145: could not find implicit value for parameter env: securesocial.core.RuntimeEnvironment[_] 
[error]  (None, Some(securesocial.views.html.mails.passwordChangedNotice(user))) 
[error]                 ^
[error] /Users/alberto/git/recommendation-system/app/security/CustomTemplatesPlugin.scala:155: could not find implicit value for parameter env: securesocial.core.RuntimeEnvironment[_] 
[error]  securesocial.views.html.notAuthorized() 
[error]          ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:4: object Token is not a member of package securesocial.core.providers 
[error] import securesocial.core.providers.Token 
[error]  ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:5: object IdentityId is not a member of package securesocial.core 
[error] import securesocial.core.IdentityId 
[error]  ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:25: not found: type Identity 
[error] passwordInfo: Option[PasswordInfo] = None) extends Identity { 
[error]             ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:16: not found: type IdentityId 
[error] identityId: IdentityId, 
[error]    ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:30: not found: type IdentityId 
[error] implicit val identityIdFormat = Json.format[IdentityId] 
[error]            ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:35: Unapply of object LoginUser has no parameters. Are you using an empty case class? 
[error] implicit val storageFormat = Json.format[LoginUser] 
[error]           ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:39: not found: type IdentityId 
[error] implicit val identityIdFormat = Json.format[IdentityId] 
[error]            ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:49: not found: type Identity 
[error] def apply(user: Identity): Option[LoginUser] = { 
[error]     ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:58: not found: type UserServicePlugin 
[error] class UserService(application: Application) extends UserServicePlugin(application) { 
[error]             ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:59: not found: type Token 
[error] private var tokens = Map[String, Token]() 
[error]         ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:69: not found: type Identity 
[error] def find(id: IdentityId): Option[Identity] = { 
[error]         ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:69: not found: type IdentityId 
[error] def find(id: IdentityId): Option[Identity] = { 
[error]    ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:72: No Json formatter found for type security.LoginUser. Try to implement an implicit Format for this type. 
[error]  val futureUser = UserServiceLogin.find(Json.obj("identityId" -> Json.toJson(id))).one 
[error]           ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:86: not found: type Identity 
[error] def findByEmailAndProvider(email: String, providerId: String): Option[Identity] = { 
[error]                  ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:88: No Json formatter found for type security.LoginUser. Try to implement an implicit Format for this type. 
[error]  val futureUser = UserServiceLogin.find(Json.obj("email" -> email)).one 
[error]           ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:97: not found: type Identity 
[error] def save(user: Identity): Identity = { 
[error]       ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:97: not found: type Identity 
[error] def save(user: Identity): Identity = { 
[error]    ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:117: not found: type Token 
[error] def save(token: Token) = { 
[error]     ^
[error] /Users/alberto/git/recommendation-system/app/security/UserService.scala:130: not found: type Token 
[error] def findToken(token: String): Option[Token] = { 
[error]          ^
[error] /Users/alberto/git/recommendation-system/conf/routes:41: value resetPassword is not a member of securesocial.controllers.Registration 
[error] GET  /reset/:token     @securesocial.controllers.Registration.resetPassword(token) 
[error] /Users/alberto/git/recommendation-system/conf/routes:36: value startResetPassword is not a member of securesocial.controllers.Registration 
[error] POST  /signup      @securesocial.controllers.Registration.startResetPassword 
[error] /Users/alberto/git/recommendation-system/conf/routes:42: value handleResetPassword is not a member of securesocial.controllers.Registration 
[error] POST  /reset/:token     @securesocial.controllers.Registration.handleResetPassword(token) 
[error] /Users/alberto/git/recommendation-system/conf/routes:49: value notAuthorized is not a member of securesocial.controllers.ProviderController 
[error] GET  /not-authorized    @securesocial.controllers.ProviderController.notAuthorized    
[error] /Users/alberto/git/recommendation-system/conf/routes:36: value startResetPassword is not a member of securesocial.controllers.Registration 
[error] POST  /signup      @securesocial.controllers.Registration.startResetPassword 
[error] /Users/alberto/git/recommendation-system/conf/routes:39: value startResetPassword is not a member of securesocial.controllers.Registration 
[error] GET  /reset      @securesocial.controllers.Registration.startResetPassword 
[error] /Users/alberto/git/recommendation-system/conf/routes:40: value startResetPassword is not a member of securesocial.controllers.Registration 
[error] POST  /reset      @securesocial.controllers.Registration.startResetPassword 
[error] /Users/alberto/git/recommendation-system/conf/routes:41: value resetPassword is not a member of securesocial.controllers.Registration 
[error] GET  /reset/:token     @securesocial.controllers.Registration.resetPassword(token) 
[error] /Users/alberto/git/recommendation-system/conf/routes:42: value handleResetPassword is not a member of securesocial.controllers.Registration 
[error] POST  /reset/:token     @securesocial.controllers.Registration.handleResetPassword(token) 
[error] /Users/alberto/git/recommendation-system/conf/routes:49: value notAuthorized is not a member of securesocial.controllers.ProviderController 
[error] GET  /not-authorized    @securesocial.controllers.ProviderController.notAuthorized    
[error] /Users/alberto/git/recommendation-system/app/views/secure/login.scala.html:5: object Registry is not a member of package securesocial.core 
[error] @import securesocial.core.AuthenticationMethod._ 
[error]       ^
[error] /Users/alberto/git/recommendation-system/app/views/secure/login.scala.html:35: not found: value Registry 
[error]   @defining(Registry.providers.all.values.filter(_.id != UsernamePassword)) { externalProviders => 
[error]     ^
[error] /Users/alberto/git/recommendation-system/app/views/secure/provider.scala.html:4: object Registry is not a member of package securesocial.core 
[error] @import securesocial.core.IdentityProvider 
[error]       ^
[error] /Users/alberto/git/recommendation-system/app/views/secure/provider.scala.html:8: object RoutesHelper is not a member of package securesocial.core.providers.utils 
[error] @import play.api.Logger 
[error] ^
[error] /Users/alberto/git/recommendation-system/app/views/secure/provider.scala.html:12: not found: value Registry 
[error] @Registry.providers.get(providerId).map { provider => 
[error]^

感謝 阿爾貝託

回答

7

已經有一個巨大的重構中securesocial 2.1.4和主人之間。

整個插件系統有蜂被刮到有利於注入組件。 Identity和IdentityId特徵已被刪除,操作現在由您自己的類型進行參數化。

UserService API也發生了很大變化,從同步到異步。

該文檔目前仍在使用中。您將不得不查看samples以瞭解這一切如何結合在一起。

@edit

關於視圖模板: securesocial.controllers.ViewTemplates現在,你可以擴展到覆蓋相應的視圖的特質。那麼您必須更改默認佈線以引入您自己的視圖提供程序。

,如果你看一下全球的樣品其創建對象MyRuntimeEnvironment

object MyRuntimeEnvironment extends RuntimeEnvironment.Default[DemoUser] { 
    override lazy val routes = new CustomRoutesService() 
    override lazy val userService: InMemoryUserService = new InMemoryUserService() 
    override lazy val eventListeners = List(new MyEventListener()) 
    } 

,你可以創建自己的ViewTemplate並覆蓋在這裏:

object MyRuntimeEnvironment extends RuntimeEnvironment.Default[DemoUser] { 
    override lazy val routes = new CustomRoutesService() 
    override lazy val userService: InMemoryUserService = new InMemoryUserService() 
    override lazy val eventListeners = List(new MyEventListener()) 
    override lazy val viewTemplates = new ViewTemplates{ 

     override def getLoginPage(form: Form[(String, String)], msg: Option[String])(implicit request: RequestHeader, lang: Lang): Html = ??? 

     override def getPasswordChangePage(form: Form[ChangeInfo])(implicit request: RequestHeader, lang: Lang): Html = ??? 

     override def getNotAuthorizedPage(implicit request: RequestHeader, lang: Lang): Html = ??? 

     override def getStartSignUpPage(form: Form[String])(implicit request: RequestHeader, lang: Lang): Html = ??? 

     override def getSignUpPage(form: Form[RegistrationInfo], token: String)(implicit request: RequestHeader, lang: Lang): Html = ??? 

     override def getResetPasswordPage(form: Form[(String, String)], token: String)(implicit request: RequestHeader, lang: Lang): Html = ??? 

     override def getStartResetPasswordPage(form: Form[String])(implicit request: RequestHeader, lang: Lang): Html = ??? 
    } 
    } 

當然,我並沒有真正建議中正確的方法是創建

class CustomViewTemplates extends ViewTemplates{ 
//... 
} 

,則

override lazy val viewTemplates = new CustomViewTemplates() 

爲ViewTemplates默認實現在securesocial.core.ViewTemplates.Default

可用於每一個「老」插件相同的機制(userService,認證店,IdGenerator,PasswordValidator,郵件模板等等)的實際列表實際上可以從securesocial.core.RuntimeEnvironment.Default

該設計已更改爲允許編譯和基於運行時的依賴項注入。它可能(不幸)不得不再次改變與播放2.4和播放3.0,這將使運行時DI成爲框架的第一類公民(雖然仍支持編譯時注入)

+0

我看到的示例在github存儲庫,但它doesn不幫助我,因爲不使用ViewTemplates – 2014-09-19 12:05:31

+0

謝謝你的回答。 我的問題是在ViewTemplates特性的實現中,我沒有看到github上的示例項目中的任何示例。 編譯器給我錯誤隱式值找不到。 – 2014-09-19 13:05:14

+0

我已經爲ViewTemplates的默認實現添加了一個鏈接...請參閱https:// github。com/jaliss/securesocial/blob/master/module-code/app/securesocial/controllers/ViewsPlugin.scala#L136 – Jean 2014-09-19 13:25:11

相關問題