斯卡拉的IntelliJ不能建立一个简单的项目(SBT能)(IntelliJ Scala canno

2019-10-23 04:39发布

我安装在我的Windows 7机器的IntelliJ IDEA社区版14.1.3。

我创建了一个简单的SBT项目中,build.sbt文件的样子

name := "SlickTest"

version := "1.0"

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  "com.typesafe.slick" %% "slick" % "3.0.0-RC3",
  "org.slf4j" % "slf4j-nop" % "1.6.4",
  "com.typesafe" % "config" % "1.0.2"

)

现在,我写了一个简单的类

import com.typesafe.config.ConfigFactory

object Foo {
  def main(args : Array[String]): Unit = {
    println("foo")
    val conf = ConfigFactory.load()
    val foo = conf.getString("derby.url")
    println(foo)
  }
}

我创建了一个在资源文件夹名为“application.conf”文件。

derby = {
  url = "foo"
}

现在,如果我去命令行,并说sbt clean compile run ,我可以看到

D:\myapps\Scala\SlickTest>sbt clean compile run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from D:\myapps\Scala\SlickTest\project
[info] Set current project to SlickTest (in build file:/D:/myapps/Scala/SlickTest/)
[success] Total time: 0 s, completed May 26, 2015 2:24:04 AM
[info] Updating {file:/D:/myapps/Scala/SlickTest/}slicktest...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 1 Scala source to D:\myapps\Scala\SlickTest\target\scala-2.11\classes...
[success] Total time: 3 s, completed May 26, 2015 2:24:07 AM
[info] Running Foo
foo
foo
[success] Total time: 0 s, completed May 26, 2015 2:24:07 AM

D:\myapps\Scala\SlickTest>

但是当我尝试打造的IntelliJ IDEA我看到在同一个项目

Error:scalac: Error: Could not find an output directory for D:\myapps\Scala\SlickTest\src\main\scala-2.11\SlickTest.scala in List((D:\myapps\scala\SlickTest\src\test\resources,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\resources,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\scala-2.11,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\scala,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\java,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\scala-2.11,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\scala,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\java,D:\myapps\scala\SlickTest\target\scala-2.11\classes))
scala.reflect.internal.FatalError: Could not find an output directory for D:\myapps\Scala\SlickTest\src\main\scala-2.11\SlickTest.scala in List((D:\myapps\scala\SlickTest\src\test\resources,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\resources,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\scala-2.11,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\scala,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\test\java,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\scala-2.11,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\scala,D:\myapps\scala\SlickTest\target\scala-2.11\classes), (D:\myapps\scala\SlickTest\src\main\java,D:\myapps\scala\SlickTest\target\scala-2.11\classes))    
    at scala.tools.nsc.settings.MutableSettings$OutputDirs.outputDirFor(MutableSettings.scala:311)    
    at scala.tools.nsc.backend.jvm.BytecodeWriters$class.outputDirectory(BytecodeWriters.scala:26)    
    at scala.tools.nsc.backend.jvm.GenASM.outputDirectory(GenASM.scala:23)    
    at scala.tools.nsc.backend.jvm.BytecodeWriters$class.getFile(BytecodeWriters.scala:41)    
    at scala.tools.nsc.backend.jvm.GenASM.getFile(GenASM.scala:23)    
    at scala.tools.nsc.backend.jvm.GenASM$JBuilder.writeIfNotTooBig(GenASM.scala:531)    
    at scala.tools.nsc.backend.jvm.GenASM$JMirrorBuilder.genMirrorClass(GenASM.scala:2835)    
    at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.emitFor$1(GenASM.scala:193)    
    at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:203)    
    at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1500)    
    at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1487)    
    at scala.tools.nsc.Global$Run.compileSources(Global.scala:1482)    
    at scala.tools.nsc.Global$Run.compile(Global.scala:1580)    
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:126)    
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:102)    
    at xsbt.CompilerInterface.run(CompilerInterface.scala:27)    
    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:483)    
    at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)    
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)    
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)    
    at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)    
    at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)    
    at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:62)
    at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:20)
    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:483)    
    at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)

有谁知道为什么不能建的IntelliJ同一个项目时,SBT可以轻松地构建它。

我搜索了几个找不到输出目录线程,但他们并没有帮助我,因为不像其他人我没有在我的路径或项目名称的大小写错误。

Answer 1:

打开项目设置和填写了输出路径输入此项目,如下面的图片。



文章来源: IntelliJ Scala cannot build a simple project (SBT can)