Sbt 在 visual studio 代码上 运行 失败

Sbt failed to run on visual studio code

我正在尝试将 visual studio 代码配置到 运行 我的 java 使用 Play 框架的项目。

安装Scala(Metal)后出现错误:

java.lang.NoSuchMethodError: sbt.Keys$.reresolveSbtArtifacts()Lsbt/SettingKey;

有人建议我应该将我的 sbt-version 更新到 1.3.0。但是更新后,就出现了这个问题

我的java版本:

openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)

build.properties中:

sbt.version=1.3.0

build.sbt中:

import com.typesafe.sbt.SbtNativePackager.autoImport.NativePackagerHelper._

name := """name"""
organization := "net.jobmanager"

version := "0.44.398"

scalaVersion := "2.12.4"

lazy val root = (project in file(".")).enablePlugins(PlayJava, DebianPlugin, SystemVPlugin)
  // .disablePlugins(PlayFilters)
  .settings(
  watchSources ++= (baseDirectory.value / "app/net/coding/jobmanagerUI/" ** "*").get
)

libraryDependencies += guice

libraryDependencies += "be.objectify" %% "deadbolt-java" % "2.6.4"

libraryDependencies += "org.assertj" % "assertj-core" % "3.6.2"

libraryDependencies += "org.mongodb.morphia" % "morphia" % "1.3.2"
//libraryDependencies += "javax.el" % "javax.el-api" % "3.0.0"
libraryDependencies += "org.mongodb.morphia" % "morphia-validation" % "1.3.2"

libraryDependencies += "com.typesafe.play" %% "play-mailer" % "6.0.1"
libraryDependencies += "com.typesafe.play" %% "play-mailer-guice" % "6.0.1"


// openstack storage
// https://mvnrepository.com/artifact/org.javaswift/joss
//libraryDependencies += "org.javaswift" % "joss" % "0.10.4"
// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk
libraryDependencies += "com.amazonaws" % "aws-java-sdk" % "1.11.741"


// WORD Apache POI
libraryDependencies += "org.apache.poi" % "poi" % "3.17"
libraryDependencies += "org.apache.poi" % "poi-ooxml" % "3.17"
// PDF exporter for Apache POI XWPF : https://mvnrepository.com/artifact/fr.opensagres.xdocreport/fr.opensagres.poi.xwpf.converter.pdf
libraryDependencies += "fr.opensagres.xdocreport" % "fr.opensagres.poi.xwpf.converter.pdf" % "2.0.2"
// https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox
libraryDependencies += "org.apache.pdfbox" % "pdfbox" % "2.0.19"

//libraryDependencies += "com.github.ozlerhakan" % "poiji" % "1.11"

// Testing libraries for dealing with CompletionStage...
libraryDependencies += "org.assertj" % "assertj-core" % "3.6.2" % Test
libraryDependencies += "org.awaitility" % "awaitility" % "2.0.0" % Test

// JSON
libraryDependencies += "com.googlecode.json-simple" % "json-simple" % "1.1.1"

//HTTP Query
libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.9"


// https://mvnrepository.com/artifact/org.mnode.ical4j/ical4j
libraryDependencies += "org.mnode.ical4j" % "ical4j" % "3.0.17"

//================================================================================
//                    prometheus
//================================================================================

//prometheus : Client
libraryDependencies += "io.prometheus" % "simpleclient" % "0.8.1"
//prometheus : Hotspot JVM metrics
libraryDependencies += "io.prometheus" % "simpleclient_hotspot" % "0.8.1"
//prometheus : Exposition HTTPServer
libraryDependencies += "io.prometheus" % "simpleclient_httpserver" % "0.8.1"
//prometheus : Pushgateway exposition
libraryDependencies += "io.prometheus" % "simpleclient_pushgateway" % "0.8.1"

//================================================================================
//                    STRIPE
//================================================================================

libraryDependencies += "com.stripe" % "stripe-java" % "17.11.0"

//================================================================================
//                    QUICKBOOKS
//================================================================================

libraryDependencies += "com.intuit.quickbooks-online" % "ipp-v3-java-devkit-pom" % "5.0.2" pomOnly()

// https://mvnrepository.com/artifact/com.intuit.quickbooks-online/ipp-v3-java-devkit
libraryDependencies += "com.intuit.quickbooks-online" % "ipp-v3-java-devkit" % "5.0.2"

// https://mvnrepository.com/artifact/com.intuit.quickbooks-online/ipp-v3-java-data
libraryDependencies += "com.intuit.quickbooks-online" % "ipp-v3-java-data" % "5.0.2"

// https://mvnrepository.com/artifact/com.intuit.quickbooks-online/ipp-v3-java-devkit-pom
libraryDependencies += "com.intuit.quickbooks-online" % "ipp-v3-java-devkit-pom" % "5.0.2" pomOnly()

// https://mvnrepository.com/artifact/com.intuit.quickbooks-online/oauth2-platform-api
libraryDependencies += "com.intuit.quickbooks-online" % "oauth2-platform-api" % "5.0.2"

//================================================================================
//                    JASPER
//================================================================================

// https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports
libraryDependencies += "net.sf.jasperreports" % "jasperreports" % "6.6.0"
// https://mvnrepository.com/artifact/com.lowagie/itext
libraryDependencies += "com.lowagie" % "itext" % "2.1.7"
// https://mvnrepository.com/artifact/org.olap4j/olap4j
libraryDependencies += "org.olap4j" % "olap4j" % "1.2.0"

//================================================================================
//                    MAILJET
//================================================================================

// https://mvnrepository.com/artifact/com.mailjet/mailjet-client
libraryDependencies += "com.mailjet" % "mailjet-client" % "4.2.0"

//================================================================================
//                    Expo Notification
//================================================================================

// https://search.maven.org/artifact/io.github.jav/expo-server-sdk/0.7.0/jar
libraryDependencies += "io.github.jav" % "expo-server-sdk" % "0.7.0"

//================================================================================
//                    TEST
//================================================================================


libraryDependencies += "org.mockito" % "mockito-core" % "1.9.5"
javaOptions in Test += "-Dconfig.file=conf/application.test.conf"

//================================================================================
//                    OTHERS
//================================================================================


routesGenerator := InjectedRoutesGenerator

// Make verbose tests
testOptions in Test := Seq(Tests.Argument(TestFrameworks.JUnit, "-a", "-v"))

// register FrontendRunHook
PlayKeys.playRunHooks += FrontendRunHook(baseDirectory.value)

scalacOptions in(Compile, doc) += "-no-java-comments"

错误发生在我运行以下命令时:

minhtam@minhtam-Vostro-15-3568:~/jobmanager$ sudo sbt run

这是错误日志:

    [info] Loading settings for project jobmanager-build-build-build from metals.sbt ...
    [info] Loading project definition from /home/minhtam/jobmanager/project/project/project
    [info] Loading settings for project jobmanager-build-build from metals.sbt ...
    [info] Loading project definition from /home/minhtam/jobmanager/project/project
    [success] Generated .bloop/jobmanager-build-build.json
    [success] Total time: 1 s, completed Jan 18, 2021, 4:22:52 PM
    [info] Loading settings for project jobmanager-build from plugins.sbt,metals.sbt ...
    [info] Loading project definition from /home/minhtam/jobmanager/project
    [success] Generated .bloop/jobmanager-build.json
    [success] Total time: 1 s, completed Jan 18, 2021, 4:22:54 PM
    [info] Loading settings for project root from build.sbt ...
    [info] Set current project to jobmanager (in build file:/home/minhtam/jobmanager/)
    [info] Updating 
    [info] Resolved  dependencies
    [warn] 
    [warn]  Note: Unresolved dependencies path:
    [error] sbt.librarymanagement.ResolveException: Error downloading com.lowagie:itext:2.1.7.js6
    [error]   Not found
    [error]   Not found
    [error]   not found: /root/.ivy2/local/com.lowagie/itext/2.1.7.js6/ivys/ivy.xml
    [error]   not found: https://repo1.maven.org/maven2/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
    [error]         at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:245)
    [error]         at lmcoursier.CoursierDependencyResolution.$anonfun$update(CoursierDependencyResolution.scala:214)
    [error]         at scala.util.Either$LeftProjection.map(Either.scala:573)
    [error]         at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:214)
    [error]         at sbt.librarymanagement.DependencyResolution.update(DependencyResolution.scala:60)
    [error]         at sbt.internal.LibraryManagement$.resolve(LibraryManagement.scala:52)
    [error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate(LibraryManagement.scala:102)
    [error]         at sbt.util.Tracked$.$anonfun$lastOutput(Tracked.scala:69)
    [error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate(LibraryManagement.scala:115)
    [error]         at scala.util.control.Exception$Catch.apply(Exception.scala:228)
    [error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate(LibraryManagement.scala:115)
    [error]         at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$adapted(LibraryManagement.scala:96)
    [error]         at sbt.util.Tracked$.$anonfun$inputChanged(Tracked.scala:150)
    [error]         at sbt.internal.LibraryManagement$.cachedUpdate(LibraryManagement.scala:129)
    [error]         at sbt.Classpaths$.$anonfun$updateTask0(Defaults.scala:2909)
    [error]         at scala.Function1.$anonfun$compose(Function1.scala:49)
    [error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219(TypeFunctions.scala:62)
    [error]         at sbt.std.Transform$$anon.work(Transform.scala:67)
    [error]         at sbt.Execute.$anonfun$submit(Execute.scala:280)
    [error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
    [error]         at sbt.Execute.work(Execute.scala:289)
    [error]         at sbt.Execute.$anonfun$submit(Execute.scala:280)
    [error]         at sbt.ConcurrentRestrictions$$anon.$anonfun$submitValid(ConcurrentRestrictions.scala:178)
    [error]         at sbt.CompletionService$$anon.call(CompletionService.scala:37)
    [error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    [error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    [error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    [error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    [error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    [error]         at java.base/java.lang.Thread.run(Thread.java:834)
    [error] (update) sbt.librarymanagement.ResolveException: Error downloading com.lowagie:itext:2.1.7.js6
    [error]   Not found
    [error]   Not found
    [error]   not found: /root/.ivy2/local/com.lowagie/itext/2.1.7.js6/ivys/ivy.xml
    [error]   not found: https://repo1.maven.org/maven2/com/lowagie/itext/2.1.7.js6/itext-2.1.7.js6.pom
    [error] Total time: 5 s, completed Jan 18, 2021, 4:23:00 PM

如您的异常所述,com.lowagie:itext 无法解决:

sbt.librarymanagement.ResolveException: Error downloading com.lowagie:itext:2.1.7.js6

请尝试将以下内容添加到您的 build.sbt:

resolvers += "itext" at "https://mvnrepository.com/artifact/com.lowagie/itext"

如其 maven page 中所述。