簡體   English   中英

IntelliJ IDEA 13 Scala插件和Eclipse Kepler編譯錯誤

[英]IntelliJ IDEA 13 Scala Plugin & Eclipse Kepler Compilation Error

IntelliJ IDEA日食

代碼:

import com.google.common.base.Joiner
import scala.collection.JavaConverters._

object MainJ extends App {
   val fantasyGeneres = Array("Space Opera", "Horror", "Magic realism", "Religion")
   val joined = Joiner.on(',').join(fantasyGeneres.toIterable.asJava)
println(joined)
}

IntelliJ IDEA錯誤:

scala: error while loading Joiner, class file 'C:\guava-    15.0.jar(com/google/common/base/Joiner.class)' is broken
(class java.lang.RuntimeException/bad constant pool tag 9 at byte 10)

Scala插件版本:

Scala -> 0.26.318
Version: 0.26.318
Date: 2013-12-04 10:46
Since: 133.124
Until: 134.0
Size: 25346.32 Kb

Eclipse錯誤:

Description Resource    Path    Location    Type
error while loading Joiner, class file 'C:\guava-15.0.jar(com/google/common/base/Joiner.class)' is broken (class java.lang.RuntimeException/bad constant pool tag 9 at byte 10) Scala       Unknown Scala Problem

請看上面的圖片,我用Guava庫和scala語言編寫了一個程序

我使用Eclipse IDE與Scala插件和IntelliJ IDEA與Scala插件上面的錯誤顯示,我無法編譯它

誰能幫我 ?

這不是IDE的錯。 實際上它是Scala編譯器的工作方式。 與Java編譯器不同,Scala編譯器需要代碼直接使用的所有庫的所有注釋。 Guava依賴於JSR-305注釋,因此您必須在構建中包含相應的JAR。

有關更多信息,請參見此處此處 這是Maven依賴描述符,從這里復制:

<dependency>
    <groupId>com.google.code.findbugs</groupId>
    <artifactId>jsr305</artifactId>
    <version>2.0.2</version>
</dependency>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM