尝试使用 sbt 导入 dbcp2 和 postgres 库时出错
Error when trying to import the dbcp2 and postgres library with sbt
我有以下 sbt 文件:
name := "data-test"
version := "0.1"
scalaVersion := "2.12.5"
libraryDependencies ++= {
val sparkVersion = "3.1.1"
val cassandraVersion = "3.0.1"
val dbcp2Version = "2.8.0"
val postgresqlVersion = "42.2.20"
Seq( "org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-streaming" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"org.apache.spark" %% "spark-streaming-kafka-0-10" % sparkVersion,
"com.datastax.spark" %% "spark-cassandra-connector" % cassandraVersion,
"org.apache.spark" %% "spark-sql-kafka-0-10" % sparkVersion,
"org.apache.commons" %% "commons-dbcp2" % dbcp2Version,
"org.postgresql" %% "postgresql" % postgresqlVersion
)
}
每当我尝试重新加载 sbt 时,我都会在尝试下载 dbcp 和 postgres 的依赖项时收到错误消息。当我在没有这两个库的情况下执行相同的过程时,sbt 重新加载成功结束。
错误是这样的:
[warn] Note: Unresolved dependencies path:
[error] stack trace is suppressed; run 'last update' for the full output
[error] stack trace is suppressed; run 'last ssExtractDependencies' for the full output
[error] (update) sbt.librarymanagement.ResolveException: Error downloading org.apache.commons:commons-dbcp2_2.12:2.8.0
[error] Not found
[error] Not found
[error] not found: C:\Users\danilo.rodrigues\.ivy2\localorg.apache.commons\commons-dbcp2_2.12.8.0\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/apache/commons/commons-dbcp2_2.12/2.8.0/commons-dbcp2_2.12-2.8.0.pom
[error] Error downloading org.postgresql:postgresql_2.12:42.2.20
[error] Not found
[error] Not found
[error] not found: C:\Users\danilo.rodrigues\.ivy2\localorg.postgresql\postgresql_2.12.2.20\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/postgresql/postgresql_2.12/42.2.20/postgresql_2.12-42.2.20.pom
[error] (ssExtractDependencies) sbt.librarymanagement.ResolveException: Error downloading org.apache.commons:commons-dbcp2_2.12:2.8.0
[error] Not found
[error] Not found
[error] not found: C:\Users\danilo.rodrigues\.ivy2\localorg.apache.commons\commons-dbcp2_2.12.8.0\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/apache/commons/commons-dbcp2_2.12/2.8.0/commons-dbcp2_2.12-2.8.0.pom
[error] Error downloading org.postgresql:postgresql_2.12:42.2.20
[error] Not found
[error] Not found
[error] not found: C:\Users\danilo.rodrigues\.ivy2\localorg.postgresql\postgresql_2.12.2.20\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/postgresql/postgresql_2.12/42.2.20/postgresql_2.12-42.2.20.pom
[error] Total time: 6 s, completed 24 de mai de 2021 16:28:53
[info] shutting down sbt server
有人可以帮助我吗?
快速回答:不要对 Java 个库使用 %%
,而是 %
。
%%
用于在库名称中自动附加 Scala 版本,如您在错误消息 Error downloading org.apache.commons:commons-dbcp2_2.12:2.8.0
中所见,其中附加了后缀 _2.12
。
更多详情请见Build.scala, % and %% symbols meaning
我有以下 sbt 文件:
name := "data-test"
version := "0.1"
scalaVersion := "2.12.5"
libraryDependencies ++= {
val sparkVersion = "3.1.1"
val cassandraVersion = "3.0.1"
val dbcp2Version = "2.8.0"
val postgresqlVersion = "42.2.20"
Seq( "org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-streaming" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"org.apache.spark" %% "spark-streaming-kafka-0-10" % sparkVersion,
"com.datastax.spark" %% "spark-cassandra-connector" % cassandraVersion,
"org.apache.spark" %% "spark-sql-kafka-0-10" % sparkVersion,
"org.apache.commons" %% "commons-dbcp2" % dbcp2Version,
"org.postgresql" %% "postgresql" % postgresqlVersion
)
}
每当我尝试重新加载 sbt 时,我都会在尝试下载 dbcp 和 postgres 的依赖项时收到错误消息。当我在没有这两个库的情况下执行相同的过程时,sbt 重新加载成功结束。
错误是这样的:
[warn] Note: Unresolved dependencies path:
[error] stack trace is suppressed; run 'last update' for the full output
[error] stack trace is suppressed; run 'last ssExtractDependencies' for the full output
[error] (update) sbt.librarymanagement.ResolveException: Error downloading org.apache.commons:commons-dbcp2_2.12:2.8.0
[error] Not found
[error] Not found
[error] not found: C:\Users\danilo.rodrigues\.ivy2\localorg.apache.commons\commons-dbcp2_2.12.8.0\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/apache/commons/commons-dbcp2_2.12/2.8.0/commons-dbcp2_2.12-2.8.0.pom
[error] Error downloading org.postgresql:postgresql_2.12:42.2.20
[error] Not found
[error] Not found
[error] not found: C:\Users\danilo.rodrigues\.ivy2\localorg.postgresql\postgresql_2.12.2.20\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/postgresql/postgresql_2.12/42.2.20/postgresql_2.12-42.2.20.pom
[error] (ssExtractDependencies) sbt.librarymanagement.ResolveException: Error downloading org.apache.commons:commons-dbcp2_2.12:2.8.0
[error] Not found
[error] Not found
[error] not found: C:\Users\danilo.rodrigues\.ivy2\localorg.apache.commons\commons-dbcp2_2.12.8.0\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/apache/commons/commons-dbcp2_2.12/2.8.0/commons-dbcp2_2.12-2.8.0.pom
[error] Error downloading org.postgresql:postgresql_2.12:42.2.20
[error] Not found
[error] Not found
[error] not found: C:\Users\danilo.rodrigues\.ivy2\localorg.postgresql\postgresql_2.12.2.20\ivys\ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/postgresql/postgresql_2.12/42.2.20/postgresql_2.12-42.2.20.pom
[error] Total time: 6 s, completed 24 de mai de 2021 16:28:53
[info] shutting down sbt server
有人可以帮助我吗?
快速回答:不要对 Java 个库使用 %%
,而是 %
。
%%
用于在库名称中自动附加 Scala 版本,如您在错误消息 Error downloading org.apache.commons:commons-dbcp2_2.12:2.8.0
中所见,其中附加了后缀 _2.12
。
更多详情请见Build.scala, % and %% symbols meaning