2011-12-19 148 views
0

我已經將簡單的代碼寫入到一個開源項目(Saiku)的文件中,在我的更改生成並編譯完成之前。Eclipse和Maven編譯差異

該程序在Centos 5.3 Eclipse(無紅X)中乾淨編譯。

然而,重新運行Maven構建腳本時,會生成編譯器錯誤(圖表1):

不會從Maven的Eclipse的Java編譯項目不同?

圖表1:

[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[67,8] illegal start of type 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[67,11] ';' expected 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[70,14] <identifier> expected 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[70,15] illegal start of type 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[71,14] <identifier> expected 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[73,14] <identifier> expected 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[75,11] illegal start of type 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[79,2] invalid method declaration; return type required 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[130,15] class, interface, or enum expected 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[130,43] class, interface, or enum expected 
[ERROR] 
[ERROR] /usr/local/.m2/repository/saiku/saiku-core/saiku-service/src/main/java/org/saiku/olap/util/formatter/HierarchicalCellSetFormatter.java:[131,8] class, interface, or enum expected 
[ERROR] 

圖表2:

import java.io.*; to the import section 

    try { 
    FileWriter fstream = new FileWriter("/usr/local/dailycandy/biserver.txt"); 
    BufferedWriter out = new BufferedWriter(fstream); 
    out.write("Hello Java"); 
    out.flush(); 
    //Close the output stream 
    out.close(); 
    } 
    catch (Exception e) 
    { 
//Catch exception if any 
System.err.println("Error: " + e.getMessage()); 
} 
+0

你能發佈完整的課程(包括你的修改)嗎?我認爲這些錯誤可能是引用了上面代碼片段的上下文。 – 2011-12-19 18:09:51

+0

Beau感謝您回覆,複製課程http://pastebin.com/0G2hw4Va – user1020656 2011-12-19 18:44:16

回答

0

已添加的代碼不是一個方法/構造/塊內等,這是不有效的Java,因此確實不編譯。

你需要像下面的東西包圍此:

public void doSomething 
{ 
    // Insert code here 
} 

或者,你可以將它放在一個現有的方法,或構造,這取決於當你需要這個代碼來執行的。

爲什麼Eclipse沒有突出顯示這個錯誤超出了我的想象。它通常會報告這一點。嘗試刷新您的項目或清理/重建,您應該看到它將無法編譯。