当使用Build.scala时,sbt maven本地解析器不起作用

时间:2014-04-20 00:57:54

标签: scala playframework sbt

我曾经在build.sbt文件中定义了我的依赖项以供我玩!应用程序,但现在我有多个项目,我现在尝试在build.scala文件中执行此操作:

resolvers += Resolver.mavenLocal

val webDependencies = Seq(
..
..
"com.example" % "blah" % "0.0.1-SNAPSHOT"
)

当我尝试运行或编译它时说它无法解决依赖性因某种原因。我在build.sbt中有完全相同的东西,它有效,但现在它没有'在build.scala中工作。

错误显示:

[info] Resolving com.example#blah;0.0.1-SNAPSHOT ...
[warn]  module not found: com.example#blah;0.0.1-SNAPSHOT
[warn] ==== local: tried
[warn]   /Users/blankman/.ivy2/local/com.example/blah/0.0.1-SNAPSHOT/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom
[warn] ==== Typesafe Releases Repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom
[warn] ==== Typesafe Releases Repository: tried
[warn]   http://repo.typesafe.com/typesafe/releases/org/blah/blah/0.0.1-SNAPSHOT/blah-0.0.1-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.example#blah;0.0.1-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

为什么它会停止工作以及如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

此解决方案适用于我:

val buildResolvers = resolvers ++= Seq(
    "Local Maven Repository"    at "file://"+Path.userHome.absolutePath+"/.m2/repository",
    "Typesafe Repo"             at "http://repo.typesafe.com/typesafe/releases/",
    "Sonatype Snapshots"        at "http://oss.sonatype.org/content/repositories/snapshots",
    "Sonatype Releases"         at "http://oss.sonatype.org/content/repositories/releases"
  )

def MyProject(name: String) = {
    Project(id = name, base = file(name)).
      settings(buildResolvers:_*)

我看到的主要区别是,我明确地将解析器设置添加到项目中。