salvob
salvob

Reputation: 1370

SBT - Unknown artifact for log4j

I can't resolve the dependencies for LOG4j for scala in my sbt project. I have a maven project with same dependencies and same scala version and it works well. This is my build.sbt

scalaVersion := "2.11.8"

libraryDependencies += "org.apache.logging.log4j" %% "log4j-core" % "2.7"

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.1"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"

This is the error that IntelliJ shows me

Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving org.scala-sbt#template-resolver;0.1 ...
[info] Resolving org.scala-tools.sbinary#sbinary_2.10;0.4.2 ...
[info] Resolving org.scala-sbt#api;0.13.13 ...
[info] Resolving org.scala-sbt#incremental-compiler;0.13.13 ...
[info] Resolving org.scala-sbt#apply-macro;0.13.13 ...
[info] Resolving org.spire-math#json4s-support_2.10;0.6.0 ...
[info] Resolving com.thoughtworks.paranamer#paranamer;2.6 ...
[info] Resolving org.scala-sbt#test-agent;0.13.13 ...
[info] Resolving org.scala-sbt#classfile;0.13.13 ...
[info] Resolving org.scala-sbt#completion;0.13.13 ...
[info] Resolving org.scala-sbt#test-interface;1.0 ...
[info] Resolving com.jcraft#jsch;0.1.50 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.6 ...
[info] Resolving org.scala-sbt#interface;0.13.13 ...
[info] Resolving org.scala-sbt#logging;0.13.13 ...
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: org.apache.logging.log4j#log4j-core_2.11;2.7: not found
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.apache.logging.log4j#log4j-core_2.11;2.7: not found
[error] Total time: 5 s, completed Feb 20, 2017 11:24:48 AM</pre><br/>See complete log in <a href="/Users/salvob/Library/Logs/IdeaIC2016.3/sbt.last.log">/Users/salvob/Library/Logs/IdeaIC2016.3/sbt.last.log</a>    enter code here

Upvotes: 1

Views: 3814

Answers (2)

dblpanther
dblpanther

Reputation: 11

With the new updates for log4j, because of the log4j zero day vulnerability the suggested code is this:

libraryDependencies += "org.apache.logging.log4j" % "log4j-api" % "2.15.0"
libraryDependencies += "org.apache.logging.log4j" % "log4j-core" % "2.15.0"

Upvotes: 1

hgrey
hgrey

Reputation: 3093

Just replace %% with % in log4j dependency, so that it becomes

   libraryDependencies += "org.apache.logging.log4j" % "log4j-core" % "2.7"

See Build.scala, % and %% symbols meaning for explanation.

As log4j is java library it does not contain scala version in artifact coordinates.

Upvotes: 2

Related Questions