8

我想试试Deadbolt。在新的 Play Framework 2.2.1 上安装它的步骤是什么?我在这里找到的是解析器依赖 项。但是我必须把解析器放在哪里?我不想使用(在 Play 2.2 中有)Build.scalabuild.sbt

这是关于plugin的一行。它去哪儿了?在我的项目中,没有也不知道 Play 2.2 是否更愿意将其放在其他地方。plugins.sbt

编辑

插件.sbt

resolvers ++= Seq(
    "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
    Resolver.url("Objectify Play Repository", url("http://schaloner.github.io/releases/"))(Resolver.ivyStylePatterns),
    Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.io/snapshots/"))(Resolver.ivyStylePatterns)
)

构建.sbt

    libraryDependencies ++= Seq(
      javaJdbc,
      javaEbean,
      cache,
      "mysql" % "mysql-connector-java" % "5.1.27",
      "org.apache.commons" % "commons-email" % "1.3.1",
      "be.objectify" %% "deadbolt-java" % "2.2-RC2"
    )    

播放控制台错误:

[info] Resolving org.hibernate.javax.persistence#hibernate-jpa-2.0-api;1.0.1.Fin[info] Resolving be.objectify#deadbolt-java_2.10;2.2-RC2 ...
[warn]  module not found: be.objectify#deadbolt-java_2.10;2.2-RC2
[warn] ==== local: tried
[warn]   /Users/johndoe/Applications/play-2.2.1/repository/local/be.objectify/deadbolt-java_2.10/2.2-RC2/ivys/ivy.xml
[warn] ==== Maven2 Local: tried
[warn]   file:/Users/johndoe/.m2/repository/be/objectify/deadbolt-java_2.10/2.2-RC2/deadbolt-java_2.10-2.2-RC2.pom
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/be/objectify/deadbolt-java_2.10/2.2-RC2/deadbolt-java_2.10-2.2-RC2.pom
[warn] ==== Typesafe Releases Repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/be/objectify/deadbolt-java_2.10/2.2-RC2/deadbolt-java_2.10-2.2-RC2.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: be.objectify#deadbolt-java_2.10;2.2-RC2: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: be.objectify#deadbolt-java_2.10;2.2-RC2: not found
[error] Total time: 3 s, completed 12-n
4

3 回答 3

9

不要添加任何东西plugins.sbt,遵循官方文档: https ://github.com/schaloner/deadbolt-2/tree/master

添加到您的build.sbt(没有,with one blank line

resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns)

libraryDependencies ++= Seq(
  ...
  "be.objectify" %% "deadbolt-java" % "2.2-RC4",
  "be.objectify" %% "deadbolt-scala" % "2.2-RC2"
)

在我使用 play 2.2.1 和我的 build.sbt 编写时,我是:

name := "crud-test"

version := "1.0-SNAPSHOT"

resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns)

libraryDependencies ++= Seq(
  javaJdbc,
  javaJpa,
  "org.postgresql" % "postgresql" % "9.2-1003-jdbc4",
  "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final",
  "org.webjars" % "webjars-play_2.10" % "2.2.1",
  "org.webjars" % "bootstrap" % "3.1.0",
  "be.objectify" %% "deadbolt-java" % "2.2-RC4",
  "be.objectify" %% "deadbolt-scala" % "2.2-RC2"
)

play.Project.playJavaSettings

从控制台运行后play reloadplay eclipse

...
[info] [SUCCESSFUL ]
[info] Done updating.
...

编辑: 不要忘记添加新的依赖项play reload之后play eclipsebuild.sbt

EDIT2: 我猜想在 Deadbolt 之后你想使用 play-authenticate 系统,因为 Deadbolt 不提供身份验证。您可以在以下位置找到 play-authenticate 系统:https ://github.com/joscha/play-authenticate 。

使用DeadBoltplay-authenticate系统,我的 build.sbt 是:

name := "crud-test"

version := "1.0-SNAPSHOT"

resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("play-easymail (release)", url("http://joscha.github.com/play-easymail/repo/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("play-easymail (snapshot)", url("http://joscha.github.com/play-easymail/repo/snapshots/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("play-authenticate (release)", url("http://joscha.github.com/play-authenticate/repo/releases/"))(Resolver.ivyStylePatterns)

resolvers += Resolver.url("play-authenticate (snapshot)", url("http://joscha.github.com/play-authenticate/repo/snapshots/"))(Resolver.ivyStylePatterns)

libraryDependencies ++= Seq(
  javaJdbc,
  javaJpa,
  "org.postgresql" % "postgresql" % "9.2-1003-jdbc4",
  "org.hibernate" % "hibernate-entitymanager" % "3.6.9.Final",
  "org.webjars" % "webjars-play_2.10" % "2.2.1" exclude("org.scala-lang", "scala-library"),
  "org.webjars" % "bootstrap" % "3.1.0",
  "be.objectify" %% "deadbolt-java" % "2.2-RC4",
  "be.objectify" %% "deadbolt-scala" % "2.2-RC2",
  "com.feth" %% "play-authenticate" % "0.5.0-SNAPSHOT"
)

play.Project.playJavaSettings
于 2014-02-13T09:18:48.670 回答
1

尝试将此添加到您的 build.sbt 文件中。它解决了我在securesocial和postgresql依赖项中遇到的问题:

resolvers += Resolver.url("sbt-plugin-releases", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
于 2014-01-19T02:47:51.027 回答
0

我不确定你为什么没有看到plugins.sbt,但根据 2.2.1 文档,它应该在那里。http://www.playframework.com/documentation/2.2.1/Build

要将依赖项添加到plugins.sbt,请在文件中包含以下行:

resolvers += Resolver.url("Objectify Play Repository", url("http://schaloner.github.io/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("Objectify Play Snapshot Repository", url("http://schaloner.github.io/snapshots/"))(Resolver.ivyStylePatterns)

addSbtPlugin("be.objectify" %% "deadbolt-java" % "2.2-RC2")
addSbtPlugin("be.objectify" %% "deadbolt-scala" % "2.2-RC2")

注意:根据您项目的需要,您可能只需要两个插件之一。

于 2013-11-12T13:47:14.817 回答