繁体   English   中英

如何使用 SBT 将 MATSim 添加到我的 Scala 项目中?

[英]How to add MATSim to my Scala project using SBT?

我正在尝试将 MATSim 与 Scala 和 SBT 一起使用。 但是,我无法在没有编译错误的情况下添加依赖项。 MATSim 使用 Maven,但我想将其添加到我的 SBT 项目中。 这是我的 build.sbt。

name := "matsim-console"

version := "0.1"

scalaVersion := "2.13.7"

lazy val matsimVersion = "13.0"

resolvers += "osgeo" at "https://repo.osgeo.org/repository/release/"
resolvers += "matsim" at "https://repo.matsim.org/repository/matsim"
resolvers += "jogl" at "https://dl.bintray.com/matsim/matsim/"
resolvers += Resolver.url("jogl1", url("https://mvnrepository.com/artifact/"))( Patterns("[organisation]/[module]/[revision]/[artifact].[ext]") )

lazy val proj = (project in file("."))
  .settings(
    libraryDependencies += "org.jogamp.jogl" % "jogl-all" % "2.4.0-matsim-1",
    libraryDependencies += "org.jogamp.gluegen" % "gluegen-rt" % "2.3.2",
    libraryDependencies += "org.matsim" % "matsim" % matsimVersion,
    libraryDependencies += "org.matsim.contrib" % "vsp" % matsimVersion,
  )

1- 为什么我需要将jog-allgluegen-rt的依赖项添加到我的 Scala 项目中? SBT 不应该导入 MATSim 及其所有依赖项吗?

2- 为什么最后一个依赖项不起作用? 我收到此错误:

[error] stack trace is suppressed; run last update for the full output
[error] (update) lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-solaris-amd64.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-solaris-amd64.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-android-armv6.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-android-armv6.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-linux-armv6.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-linux-armv6.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-solaris-i586.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-solaris-i586.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-android-armv6.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-android-armv6.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-linux-armv6hf.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-linux-armv6hf.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-linux-armv6.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-linux-armv6.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-linux-armv6hf.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-linux-armv6hf.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-android-aarch64.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-android-aarch64.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-solaris-i586.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-solaris-i586.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-android-aarch64.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/jogl/jogl-all/2.4.0-matsim-1/jogl-all-2.4.0-matsim-1-natives-android-aarch64.jar
[error] https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-solaris-amd64.jar: not found: https://repo.matsim.org/repository/matsim/org/jogamp/gluegen/gluegen-rt/2.4.0-matsim-1/gluegen-rt-2.4.0-matsim-1-natives-solaris-amd64.jar

为什么我需要在我的Scala项目中添加jog-all和gluegen-rt的依赖? SBT 不应该导入 MatSim 及其所有依赖项吗?

对。 你不需要,这就是像 SBT 这样的依赖管理工具的目的。 直接添加你需要的依赖,传递依赖就会自动拉取。

为什么最后一个依赖项不起作用? 我收到这个错误

因为它以某种方式寻找不存在的依赖项(或者至少不在您提供的存储库中)。

您应该使用sbt dependencyTree (或变体)来更好地查看依赖项并了解为什么需要此依赖项。

当我切换到 Java 11 时,它应该正常工作。

暂无
暂无

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

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