我正在尝试使用 Scala 设置 ElasicSearch 客户端。我是 Scala 新手,所以我正在遵循一些在线教程的建议elastic4s-client-esjava
。我已经在我的目录中进行了该设置,build.sbt
其余库依赖项如下:
name := "ElasticSearchService"
version := "0.1"
scalaVersion := "3.5.2"
libraryDependencies ++= Seq(
"org.postgresql" % "postgresql" % "42.3.1",
"nl.gn0s1s" %% "elastic4s-client-esjava" % "8.11.5",
"nl.gn0s1s" %% "elastic4s-core" % "8.11.5"
)
当我尝试运行时sbt run
出现错误sbt.librarymanagement.ResolveException: Error downloading nl.gn0s1s:elastic4s-client-esjava_3:8.11.5 NOT FOUND
。我已验证软件包和版本在此处存在:https://mvnrepository.com/artifact/com.sksamuel.elastic4s/elastic4s-client-esjava和https://mvnrepository.com/artifact/com.sksamuel.elastic4s/elastic4s-core。我想知道我的设置或配置是否有误。在我添加 ElasticSearch 库依赖项之前,该项目运行良好(仅使用 postgres 依赖项)。
任何关于如何解决此问题的帮助都将不胜感激!完整的错误日志如下,供参考:
env@C02FD6JFMD6R-MacBook-Pro ElasticSearchService % sbt run
[info] welcome to sbt 1.10.3 (Homebrew Java 23)
[info] loading project definition from /Users/env/Desktop/ElasticSearchService/ElasticSearchService/project
[info] loading settings for project elasticsearchservice from build.sbt ...
[info] set current project to ElasticSearchService (in build file:/Users/env/Desktop/ElasticSearchService/)
[info] Updating elasticsearchservice_3
[info] Resolved elasticsearchservice_3 dependencies
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading nl.gn0s1s:elastic4s-client-esjava_3:8.11.5
[error] Not found
[error] Not found
[error] not found: /Users/env/.ivy2/localnl.gn0s1s/elastic4s-client-esjava_3/8.11.5/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/nl/gn0s1s/elastic4s-client-esjava_3/8.11.5/elastic4s-client-esjava_3-8.11.5.pom
[error] Error downloading nl.gn0s1s:elastic4s-core_3:8.11.5
[error] Not found
[error] Not found
[error] not found: /Users/env/.ivy2/localnl.gn0s1s/elastic4s-core_3/8.11.5/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/nl/gn0s1s/elastic4s-core_3/8.11.5/elastic4s-core_3-8.11.5.pom
[error] at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:346)
[error] at lmcoursier.CoursierDependencyResolution.$anonfun$update$39(CoursierDependencyResolution.scala:315)
[error] at scala.util.Either$LeftProjection.map(Either.scala:573)
[error] at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:315)
[error] at sbt.librarymanagement.DependencyResolution.update(DependencyResolution.scala:60)
[error] at sbt.internal.LibraryManagement$.resolve$1(LibraryManagement.scala:60)
[error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$12(LibraryManagement.scala:142)
[error] at sbt.util.Tracked$.$anonfun$lastOutput$1(Tracked.scala:74)
[error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11(LibraryManagement.scala:144)
[error] at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11$adapted(LibraryManagement.scala:131)
[error] at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:220)
[error] at sbt.internal.LibraryManagement$.cachedUpdate(LibraryManagement.scala:169)
[error] at sbt.Classpaths$.$anonfun$updateTask0$1(Defaults.scala:3894)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] at sbt.Execute.work(Execute.scala:292)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error] at java.base/java.lang.Thread.run(Thread.java:1575)
[error] (update) sbt.librarymanagement.ResolveException: Error downloading nl.gn0s1s:elastic4s-client-esjava_3:8.11.5
[error] Not found
[error] Not found
[error] not found: /Users/env/.ivy2/localnl.gn0s1s/elastic4s-client-esjava_3/8.11.5/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/nl/gn0s1s/elastic4s-client-esjava_3/8.11.5/elastic4s-client-esjava_3-8.11.5.pom
[error] Error downloading nl.gn0s1s:elastic4s-core_3:8.11.5
[error] Not found
[error] Not found
[error] not found: /Users/env/.ivy2/localnl.gn0s1s/elastic4s-core_3/8.11.5/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/nl/gn0s1s/elastic4s-core_3/8.11.5/elastic4s-core_3-8.11.5.pom
[error] Total time: 1 s, completed Oct 23, 2024, 9:47:03 a.m.
是的,抱歉说得不清楚。似乎在某个时间点,该库的所有者从使用域/组织的sksamuel
com.sksamuel.elastic4s
更改为使用域/组织的Philippusnl.gn0s1s
。(如果我没记错的话,这实际上是最近的事,但我已经有一段时间没有看过与ElasticSearch相关的东西了)。
因此,较新版本位于
nl.gn0s1s
:https://mvnrepository.com/artifact/nl.gn0s1s/elastic4s-core,较旧版本位于com.sksamuel.elastic4s
:https ://mvnrepository.com/artifact/com.sksamuel.elastic4s/elastic4s-core8.15.3
因此,您可以使用空间中发布的最新版本nl.gn0s1s
:。或者使用您最初发布的版本;
8.11.5
,但将空间更改为com.sksamuel.elastic4s
IMHO,最好使用最新版本,但您可能正在遵循过时的教程,因此坚持使用该教程的版本可能更容易。