在Play Framework 2.2.1上安装Deadbolt的解决方案依赖

时间:2013-11-12 11:55:38

标签: scala playframework sbt playframework-2.2 deadbolt

我想试试Deadbolt。在新的Play Framework 2.2.1上安装它的步骤是什么? 我发现的是解析器依赖关系 here。但是我必须把解析器放在哪里?我不想使用Build.scala(在Play 2.2中有build.sbt

here是关于插件的一行。去哪儿了?在我的项目中没有plugins.sbt并且不知道Play 2.2是否更喜欢将其放在别处。

编辑

plugin.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)
)

build.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

3 个答案:

答案 0 :(得分: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编写im时,我的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不提供身份验证。您可以在https://github.com/joscha/play-authenticate上找到播放验证系统。

使用 DeadBolt play-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

答案 1 :(得分:1)

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

resolvers += Resolver.url("sbt-plugin-releases", url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

答案 2 :(得分: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")

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