java eclipse常見錯誤處理
一、
1)報錯資訊
HDFSOperatorUtil cannot be resolved
無法解析HDFSOperatorUtil
2)報錯說明:
說明:沒有自定義/引入 HDFSOperatorUtil類,可以藉助彈出窗進行快速建立。
3)解決方法:
1)報錯資訊:
The method copyLocalFileToHdfs(Configuration, String, String, boolean) is undefined for the type HDFSOperatorUtil
方法copyLocalFileToHdfs(配置、字串、字串、布林值)對於型別HDFSOperatorUtil沒有定義
2)報錯說明:
說明:剛剛只是自定義的類,相應方法也需要在類內部定義,選擇第一個進行快速建立類
3)解決方法:
二
1)報錯資訊:
The method run(Configuration, Tool, String[]) in the type ToolRunner is not applicable for the arguments (Configuration, DataDistribute4BDBDriver, String[])
ToolRunner型別中的方法run(Configuration, Tool, String[])不適用於引數(Configuration, DataDistribute4BDBDriver, String[])
2)報錯程式碼:
//下面是報錯的run方法
try {
ToolRunner.run(ConfigurationUtil.conf,new DataDistribute4BDBDriver(), args);
} catch (Exception e) {
e.printStackTrace();
}
//以下是ToolRunner對run方法的定義
public static int run(Configuration conf, Tool tool, String[] args)
throws Exception{
if (conf == null) {
conf = new Configuration();
}
GenericOptionsParser parser = new GenericOptionsParser(conf, args);
//set the configuration back, so that Tool can configure itself
tool.setConf(conf);
//get the args w/o generic hadoop args
String[] toolArgs = parser.getRemainingArgs();
return tool.run(toolArgs);
}
3)報錯說明
說明:此處呼叫的run方法中傳入的引數與類ToolRunner中run方法定義的引數不一致。此處我檢查發現ToolRunner中run方法第二次引數是定義的Tool物件,呼叫的時候傳入的是子類物件DataDistribute4BDBDriver,但此處沒有識別出子類物件,檢查發現是子類中沒有implements Tool
4)解決方法:
DataDistribute4BDBDriver類後加上implements Tool
三、
1)報錯資訊:
The method run(String[]) of type DataDistribute4BDBDriver must override or implement a supertype method
DataDistribute4BDBDriver型別的方法run(String[])必須覆蓋或實現超型別方法
2)報錯程式碼:
@Override
public int run(String[] otherArgs) throws Exception {
...
return 0;
}
2)報錯說明:
說明該類沒有繼承其他類,但是在該類中定義的這個run方法還使用了Override修飾了
3)解決方法:
該類應該繼承另一個類Tool(Tool類中定義了可以被繼承的run方法)
四、
1)報錯資訊:
The type DataDistribute4BDBDriver must implement the inherited abstract method Tool.getSourceVersions()
2)報錯說明:
說明該類實現了抽象的Tool類,但是沒有實現抽象類中的方法
3)解決方法:
點選報錯資訊下的第一行直接進行快速實現即可。