如何解决ElasticSearch库依赖错误

问题描述 投票:0回答:1

我正在尝试使用 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-esjavahttps://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.
scala elasticsearch
1个回答
0
投票

是的,抱歉没说清楚。似乎在某个时间点,图书馆从 sksamuel 更换了所有者;谁使用了

com.sksamuel.elastic4s
Philippus 的域名/组织;谁正在使用该域名/组织
nl.gn0s1s

(IIRC,这实际上是最近的事,但自从我查看任何与 ElasticSearch 相关的内容以来已经有一段时间了).

因此,较新的版本位于

nl.gn0s1s
空间:https://mvnrepository.com/artifact/nl.gn0s1s/elastic4s-core,旧版本位于
com.sksamuel.elastic4s
空间:https://mvnrepository .com/artifact/com.sksamuel.elastic4s/elastic4s-core

因此,您可以使用最新版本:

8.15.3
nl.gn0s1s
空间中发布。
或者使用您最初发布的版本;
8.11.5
,但是将空格改为
com.sksamuel.elastic4s

恕我直言,最好使用最新版本,但您可能正在遵循“过时的”教程,因此坚持使用该教程的版本可能会更容易。

© www.soinside.com 2019 - 2024. All rights reserved.