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)解决方法:
点击报错信息下的第一行直接进行快速实现即可。

猜你喜欢

转载自blog.csdn.net/weixin_40235225/article/details/85012720
今日推荐