2011-09-19 897 views
5

我正在使用IDEA 10.5.2和Scala插件版本0.4.1395以及IDE附帶的標準Maven集成插件。我有一個Scala 2.8.0項目與上述設置,我想升級到Scala 2.9.1。我對pom.xml進行了必要的更改。下面是我的pom.xml的相關章節:在IDEA中的Maven項目中升級Scala版本

插件部分:

<plugin> 
    <groupId>org.scala-tools</groupId> 
    <artifactId>maven-scala-plugin</artifactId> 
    <executions> 
     <execution> 
     <id>compile</id> 
     <goals> 
      <goal>compile</goal> 
     </goals> 
     <phase>compile</phase> 
     </execution> 
     <execution> 
     <id>test-compile</id> 
     <goals> 
      <goal>testCompile</goal> 
     </goals> 
     <phase>test-compile</phase> 
     </execution> 
     <execution> 
     <phase>process-resources</phase> 
     <goals> 
      <goal>compile</goal> 
     </goals> 
     </execution> 
    </executions> 
    </plugin> 

依賴性部分:

<dependency> 
    <groupId>org.scala-lang</groupId> 
    <artifactId>scala-compiler</artifactId> 
    <version>2.9.1</version> 
</dependency> 
<dependency> 
    <groupId>org.scala-lang</groupId> 
    <artifactId>scala-library</artifactId> 
    <version>2.9.1</version> 
</dependency> 

我有斯卡拉2.9.1我的機器上安裝。

在我的項目設置中,在Scala構面中,編譯器實例化部分有幾個「編譯器庫」選項。不過,我的項目並沒有選擇任何一個。

當我選擇Maven: org.scala-lang:scala-compiler-bundle:2.9.1,我得到以下錯誤:

Cannot compile Scala files.
Please, adjust compiler library in Scala facet: unable to read scala-library-2.9.1.jar version.

當我選擇Maven: org.scala-lang:scala-compiler:2.9.1,我得到以下錯誤:

Cannot compile Scala files.
Please, adjust compiler library in Scala facet: no scala-library*.jar found.

當我選擇Maven: org.scala-lang:scala-library:2.9.1,我得到以下錯誤:

Cannot compile Scala files.
Please, adjust compiler library in Scala facet: no scala-compiler*.jar found.

我在做什麼NG?我應該怎樣做才能讓我的項目建立起來?

請注意,我第一次使用構建工具。任何幫助將不勝感激。謝謝!

+0

你能通過「mvn compile」在控制檯上編譯你的項目嗎? –

回答

3

如果您正在IDEA中使用Maven項目,則更改Scala版本通常非常簡單。

首先,您必須確保IDEA正在使用您的maven項目配置。你可以通過右鍵點擊pom.xml來檢查。如果你看到一個菜單項「Add as maven project」(或類似的東西),點擊它。否則,你應該看到一個名爲「Maven」的子菜單,這意味着你的Maven項目已經正確配置。

現在,您可以在您的pom.xml中更改Scala版本,並且IDEA應立即下載相應的軟件包並在項目設置中更改Scala編譯器(如果您已啓用自動導入pom文件)。否則,IDEA會彈出一條消息,允許您手動執行pom文件導入。

但是,我沒有用Scala插件0.4.1395測試這個工作流程,因爲我在這個插件版本中遇到了一些麻煩。我終於回到了國際海事組織非常穩定的0.4.1385版本。如果你對Scala插件有任何問題,我建議你也一樣。

0

你一定想要使用「捆綁」庫。這似乎是由IDEA專門爲此設置創建的。也許其中一個罐子是腐敗的?我會嘗試從本地Maven存儲庫中刪除所有內容,並讓Maven再次下載它。