0

I have the following sbt file:

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
  )
}

Whenever I try to reload the sbt, I get an error message when trying to download the dependencies of dbcp and postgres. When I do the same procedure without these two libraries the sbt reload ends successfully.

The erro like this:

[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\2.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\42.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\2.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\42.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

Can someone help me?

Danilo Rodrigues
  • 373
  • 3
  • 17

1 Answers1

1

Quick answer: don't use %% for Java libraries but rather %.

%% is used to automatically append the Scala version in the library name as can be seen in your error messages Error downloading org.apache.commons:commons-dbcp2_2.12:2.8.0 where suffix _2.12 is appended.

More details at Build.scala, % and %% symbols meaning

Gaël J
  • 11,274
  • 4
  • 17
  • 32