我试过maven回购:
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-common</artifactId>
<version>2.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-yarn-api -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-api</artifactId>
<version>2.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-yarn-client -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-client</artifactId>
<version>2.7.2</version>
</dependency>
然后我的java代码:
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.hadoop.yarn.api.records.*;
import org.apache.hadoop.yarn.client.api.YarnClient;
import org.apache.hadoop.yarn.client.api.YarnClientApplication;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
public static void main(String[] args) {
YarnConfiguration yarnConfiguration = new YarnConfiguration();
YarnClient yarnClient = YarnClient.createYarnClient();
yarnClient.init(yarnConfiguration);
yarnClient.start();
}
intellij ide显示“cannot solve method init”和“cannot solve method start”。
然后我尝试使用jar版本的3.1.1而不是“2.7.2”。同样的结果。那么我的代码出了什么问题,如何修复呢?
1条答案
按热度按时间tag5nh1u1#
init和start方法派生自abstractservice类。您需要验证yarnclient和abstractservice的版本是否相同。
转到yarnclient并检查它所引用的jar,然后从yarn客户机中单击abstractservice父级并检查其版本。
根据abstractservice版本更改yarnclient版本。
我也有同样的问题,它对我有用。版本2.6.5。