作为一名新手开发者,我正在开展我的第一个大型项目。
我发现我需要一个外部库(junrar),所以我下载了sbt并制作了一个简单的build.sbt。但是现在当我尝试运行我的程序时(使用Intellij),我收到了大量错误消息。
Information:8/23/16, 8:13 PM - Compilation completed with 1 error and 8 warnings in 10s 420ms
Error:scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
Error compiling sbt component 'compiler-interface-2.9.1.final-52.0'
at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1$$anonfun$apply$2.apply(AnalyzingCompiler.scala:145)
at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1$$anonfun$apply$2.apply(AnalyzingCompiler.scala:142)
at sbt.IO$.withTemporaryDirectory(IO.scala:291)
at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1.apply(AnalyzingCompiler.scala:142)
at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1.apply(AnalyzingCompiler.scala:139)
at sbt.IO$.withTemporaryDirectory(IO.scala:291)
at sbt.compiler.AnalyzingCompiler$.compileSources(AnalyzingCompiler.scala:139)
at sbt.compiler.IC$.compileInterfaceJar(IncrementalCompiler.scala:52)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$.org$jetbrains$jps$incremental$scala$local$CompilerFactoryImpl$$getOrCompileInterfaceJar(CompilerFactoryImpl.scala:87)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$$anonfun$getScalac$1.apply(CompilerFactoryImpl.scala:44)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$$anonfun$getScalac$1.apply(CompilerFactoryImpl.scala:43)
at scala.Option.map(Option.scala:146)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.getScalac(CompilerFactoryImpl.scala:43)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.createCompiler(CompilerFactoryImpl.scala:22)
at org.jetbrains.jps.incremental.scala.local.CachingFactory$$anonfun$createCompiler$1.apply(CachingFactory.scala:24)
at org.jetbrains.jps.incremental.scala.local.CachingFactory$$anonfun$createCompiler$1.apply(CachingFactory.scala:24)
at org.jetbrains.jps.incremental.scala.local.Cache$$anonfun$getOrUpdate$2.apply(Cache.scala:20)
at scala.Option.getOrElse(Option.scala:121)
at org.jetbrains.jps.incremental.scala.local.Cache.getOrUpdate(Cache.scala:19)
at org.jetbrains.jps.incremental.scala.local.CachingFactory.createCompiler(CachingFactory.scala:23)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:22)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:67)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:24)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Warning:scalac: error: error while loading CharSequence, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken
(bad constant pool tag 18 at byte 10)
Warning:scalac: error: error while loading AnnotatedElement, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class)' is broken
(bad constant pool tag 18 at byte 76)
Warning:scalac: error: error while loading Arrays, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre/lib/rt.jar(java/util/Arrays.class)' is broken
(bad constant pool tag 18 at byte 765)
Warning:scalac: error: error while loading Comparator, class file '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre/lib/rt.jar(java/util/Comparator.class)' is broken
(bad constant pool tag 18 at byte 20)
Warning:scalac: /var/folders/ly/9qm0nrln35ddtk1xyzmpw8n00000gn/T/sbt_d176391c/ExtractAPI.scala:479: error: java.util.Comparator does not take type parameters
Warning:scalac: private[this] val sortClasses = new Comparator[Symbol] {
Warning:scalac: ^
Warning:scalac: 5 errors found
build.sbt:
name := "CViewerMain"
version := "0.0.1"
scalaVersion := "2.9.1"
libraryDependencies += "com.github.junrar" % "junrar" % "0.7"
// for debugging sbt problems
//logLevel := Level.Debug
scalacOptions += "-deprecation"
答案 0 :(得分:0)
有几件事情需要到位。
在IntelliJ方面,您需要由SBT
构建模块。打开您的项目结构'然后点击' Modules'。在中间列应该是正在构建的所有模块。点击您的SBT
模块,然后在右侧选择SBT
标签。如果这一切都有效,那你就行了。看起来应该是这样的:
在SBT配置方面,您需要确保已启用the IntelliJ plugin。通常这将在build/plugins.sbt
文件中。会有这样的一行:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0") // For IntelliJ
应该。如果您的IntelliJ显示不同的内容,请尝试重新创建项目并指定它是SBT项目。执行此操作时,请指向根级build.sbt
文件。
要确认您的sbt文件是否有效,请转到项目根目录的命令行并执行sbt
。如果加载,IntelliJ应该能够从那里获取它。回到IntelliJ,打开你的控制台并运行同样的东西。 (同样,这应该有效。)一旦SBT加载,执行任务以运行您的应用程序。如果此处出现错误,则应该更加详细,允许您更正。