为什么激活器无法解析本地maven存储库中的自定义依赖关系?

时间:2014-09-30 13:19:50

标签: playframework sbt mailchimp playframework-2.3 typesafe-activator

我正在使用Java编写Play 2.3.2应用程序。

我已经分发了邮件chimp java api wrapper repository,我已经扩展了它并用2.0.1.2-beta更改了模块版本。

我已将模块安装到本地maven存储库中。然后,我试图从我的Play应用程序的构建中引用它,但是play shell(update)中的activator update命令给出了以下错误:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.ecwid#ecwid-mailchimp;2.0.1.2-beta: several problems occurred while resolving dependency: com.ecwid#ecwid-mailchimp;2.0.1.2-beta {compile=[default(compile)]}:
[warn]  URI has an authority component
[warn]  URI has an authority component
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: unresolved dependency: com.ecwid#ecwid-mailchimp;2.0.1.2-beta: several problems occurred while resolving dependency: com.ecwid#ecwid-mailchimp;2.0.1.2-beta {compile=[default(compile)]}:
    URI has an authority component
    URI has an authority component
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:217)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:126)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:125)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:115)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:115)

...

[error] (*:update) sbt.ResolveException: unresolved dependency: com.ecwid#ecwid-mailchimp;2.0.1.2-beta: several problems occurred while resolving dependency: com.ecwid#ecwid-mailchimp;2.0.1.2-beta {compile=[default(compile)]}:
[error]     URI has an authority component
[error]     URI has an authority component

这是我的副本build.sbt文件的一部分:

resolvers ++= Seq(
    Resolver.sonatypeRepo("snapshots"),
    "Local Play Repository" at "file://$HOME/.ivy2/local",
    "Local Maven Repository" at "file://$HOME/.m2/repository"
)

libraryDependencies ++= Seq(
    "com.ecwid" % "ecwid-mailchimp" % "2.0.1.2-beta"
)

怎么了?

1 个答案:

答案 0 :(得分:1)

当您遇到错误时,sbt会告诉您运行last *:update以查看完整输出:

[trace] Stack trace suppressed: run last *:update for the full output.

在复制案例时,我发现last *:update非常有用,因为它告诉我:

[debug] CLIENT ERROR: Not Found url=https://oss.sonatype.org/content/repositories/snapshots/com/ecwid/ecwid-mailchimp/2.0.1.2-beta/ecwid-mailchimp-2.0.1.2-beta.pom
[debug]     sonatype-snapshots: no ivy file found for com.ecwid#ecwid-mailchimp;2.0.1.2-beta
[debug]         tried file://$HOME/.ivy2/local/com/ecwid/ecwid-mailchimp/2.0.1.2-beta/ecwid-mailchimp-2.0.1.2-beta.pom
[debug] problem occurred while resolving dependency: com.ecwid#ecwid-mailchimp;2.0.1.2-beta {compile=[default(compile)]} with Local Play Repository: java.lang.IllegalArgumentException: URI has an authority component
[debug]     at java.io.File.<init>(File.java:423)
[debug]     at sbt.IO$.toFile(IO.scala:76)
[debug]     at sbt.ConvertResolver$LocalIfFileRepo.getResource(ConvertResolver.scala:222)

我认为$HOME已经解决,因此问题就解决了。

删除"Local Play Repository" at "file://$HOME/.ivy2/local"并重新开始。它默认包含在内,您不需要在构建中明确地使用它。

您应该使用Path.userHome.absolutePath而不是$HOME,如Resolvers中所述:

  

如果您将其添加为本地Maven存储库,它可以搜索您的本地Maven存储库   存储库:

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
     

或,为方便起见:

resolvers += Resolver.mavenLocal

使用以下build.sbt

resolvers ++= Seq(
    Resolver.sonatypeRepo("snapshots"),
    Resolver.mavenLocal
)

libraryDependencies ++= Seq(
    "com.ecwid" % "ecwid-mailchimp" % "2.0.1.2-beta"
)

update停滞无法解决com.ecwid#ecwid-mailchimp;2.0.1.2-beta另一个问题:

> update
[info] Updating {file:/Users/jacek/sandbox/uri-authority/}uri-authority...
[info] Resolving com.ecwid#ecwid-mailchimp;2.0.1.2-beta ...
[warn]  module not found: com.ecwid#ecwid-mailchimp;2.0.1.2-beta
[warn] ==== local: tried
[warn]   /Users/jacek/.ivy2/local/com.ecwid/ecwid-mailchimp/2.0.1.2-beta/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/com/ecwid/ecwid-mailchimp/2.0.1.2-beta/ecwid-mailchimp-2.0.1.2-beta.pom
[warn] ==== sonatype-snapshots: tried
[warn]   https://oss.sonatype.org/content/repositories/snapshots/com/ecwid/ecwid-mailchimp/2.0.1.2-beta/ecwid-mailchimp-2.0.1.2-beta.pom
[warn] ==== Maven2 Local: tried
[warn]   file:/Users/jacek/.m2/repository/com/ecwid/ecwid-mailchimp/2.0.1.2-beta/ecwid-mailchimp-2.0.1.2-beta.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.ecwid#ecwid-mailchimp;2.0.1.2-beta: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]      com.ecwid:ecwid-mailchimp:2.0.1.2-beta (/Users/jacek/sandbox/uri-authority/build.sbt#L7-10)
[warn]        +- default:uri-authority_2.10:0.1-SNAPSHOT
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.ecwid#ecwid-mailchimp;2.0.1.2-beta: not found
[error] Total time: 1 s, completed Sep 30, 2014 11:39:21 PM