简体   繁体   English

SBT,如何将非托管JAR添加到IntelliJ?

[英]SBT, how to add unmanaged JARs to IntelliJ?

I have build.sbt file: 我有build.sbt文件:

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. 如果我使用sbt run,则运行正常,但无法从IntelliJ运行。

I receive error: 我收到错误消息:

java.lang.UnsatisfiedLinkError: no opencv_java331 in java.library.path java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_java331

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? 我的问题是:是否可以指定build.sbt以使用指定的库自动创建IntelliJ项目?

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. 我会说尝试:将依赖项拖放到/ lib中,该依赖项应位于项目的根目录中,如果不存在则创建它。

Run commands: sbt reload sbt update 运行命令: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 最后,您可以尝试执行以下操作:文件->项目结构->模块->然后将所有模块标记为1至3,将其删除(不用担心不会删除您的文件)->点击绿色加号并选择导入模块->选择项目的根目录,然后应该刷新它

If none of these help, I'm out of ideas. 如果没有这些帮助,我就没主意了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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