简体   繁体   中英

SBT, how to add unmanaged JARs to IntelliJ?

I have build.sbt file:

import sbt.Keys.libraryDependencies

lazy val scalatestVersion = "3.0.4"
lazy val scalaMockTestSupportVersion = "3.6.0"
lazy val typeSafeConfVersion = "1.3.2"
lazy val scalaLoggingVersion = "3.7.2"
lazy val logbackClassicVersion = "1.2.3"

lazy val commonSettings = Seq(
  organization := "com.stulsoft",
  version := "0.0.1",
  scalaVersion := "2.12.4",
  scalacOptions ++= Seq(
    "-feature",
    "-language:implicitConversions",
    "-language:postfixOps"),
  libraryDependencies ++= Seq(
    "com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion,
    "ch.qos.logback" % "logback-classic" % logbackClassicVersion,
    "com.typesafe" % "config" % typeSafeConfVersion,
    "org.scalatest" %% "scalatest" % scalatestVersion % "test",
    "org.scalamock" %% "scalamock-scalatest-support" % scalaMockTestSupportVersion % "test"
  )
)

unmanagedJars in Compile += file("lib/opencv-331.jar")

lazy val pimage = project.in(file("."))
  .settings(commonSettings)
  .settings(
    name := "pimage"
  )

parallelExecution in Test := true

It is working fine, if I use sbt run, but I cannot run from IntelliJ.

I receive error:

java.lang.UnsatisfiedLinkError: no opencv_java331 in java.library.path

I can add manually (File->Project Structure->Libraries->+ necessary dir). My question is: is it possible to specify build.sbt that it will automatically create IntelliJ project with specified library?

I would say try to: drag and drop the dependency into the /lib which should be in the root directory of your project, if it's not there create it.

Run commands: sbt reload sbt update

Lastly you could try something like: File -> Project Structure -> Modules -> then mark all the modules usually 1 to 3, delete them (don't worry won't delete your files) -> hit the green plus sign and select Import Module -> select root directory of your project and it should then refresh it

If none of these help, I'm out of ideas.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM