I have a Java Play project and I added Snake Yaml to my class path.
libraryDependencies ++= Seq("org.yaml" % "snakeyaml" % "1.16")
This works great, my app can import org.yaml
.
However, SBT cannot import org.yaml
. It does not have access to libraryDependencies
for some reason.
If I add import org.yaml.snakeyaml.Yaml
to project/commons.scala
, I get an error when I compile with activator compile
.
[error] <path to project>/project/commons.scala:2: object yaml is not a member of package org
[error] import org.yaml.snakeyaml.Yaml
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
How do I get make jars accessible within SBT?
Adding a dependency X to the source code of the project is not the same as adding a dependency X to your build code (a dependency to be used inside build.sbt
, project/*.scala
, etc.)
If that is what you are trying to do then you need to add the library dependency inside your project folder.
For example, just add libraryDependencies ++= Seq("org.yaml" % "snakeyaml" % "1.16")
inside project/build.sbt
(in contrast to adding in the normal ./build.sbt
file).
Structure:
.
├── build.sbt
└── project
└── build.sbt
build.sbt
import org.yaml.snakeyaml.Yaml
name := "hello"
project/build.sbt
libraryDependencies ++= Seq("org.yaml" % "snakeyaml" % "1.16")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.