【问题标题】:UNRESOLVED DEPENDENCIES installing Deadbolt on Play Framework 2.2.1在 Play Framework 2.2.1 上安装 Deadbolt 的未解决依赖项
【发布时间】:2013-11-24 13:28:52
【问题描述】:

我想试试 Deadbolt。在新的 Play Framework 2.2.1 上安装它的步骤是什么? 我发现的是 resolversdependencies 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

【问题讨论】:

  • 为什么要避免 Build.scala?另外,你确定没有 plugins.sbt 吗? 2.2 文档说它应该在那里。
  • 无需在Build.scala 上回答我的问题。查看文档后,我看到它已被替换。对于没有plugins.sbt的问题,可以尝试将文件添加到project/目录下。

标签: scala playframework sbt playframework-2.2 deadbolt


【解决方案1】:

不要在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.
...

编辑:build.sbt添加新的依赖后别忘了做play reloadplay eclipse

EDIT2: 我猜想在 Deadbolt 之后你想使用 play-authenticate 系统,因为 Deadbolt 不提供身份验证。你可以在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

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

      我不确定您为什么没有看到 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")
      

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

      【讨论】:

      • 您可能还需要添加解析器。我将编辑我的答案以包含添加这些的语法。
      • 谢谢。我有一个疑问:addSbtPlugin(string_here) 相当于这样做:libraryDependencies ++= Seq(string_here) 在 build.sbt 文件中?
      • 没错。在构建文件中,会创建一个 Seq,然后将 addSbtPlugin(或类似函数)应用于 Seq 中的每个项目。
      • 好的。只有最后一件理论上的事情:我必须添加两个解析器行?它们之间有什么区别,为什么我需要两者?谢谢!
      • 您可能不需要这两个。您可能可以删除第二个解析器并很好地解析您的插件。同样,您可能不需要 deadbolt-scala 和 deadbolt-java(取决于您的项目)。
      猜你喜欢
      • 1970-01-01
      • 2017-06-23
      • 2013-11-25
      • 2012-10-15
      • 2015-06-08
      • 1970-01-01
      • 2018-08-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多