maven intellij java mapreduce测试程序

pw136qt2  于 2021-06-04  发布在  Hadoop
关注(0)|答案(1)|浏览(424)

我在intellij中创建了一个maven项目,其中包含三个类文件:

package mavenKris;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: kshk
 * Date: 11/27/13
 * Time: 2:27 PM
 * To change this template use File | Settings | File Templates.
 */
public class WordMapper extends Mapper<Text,Text,Text,Text> {
    private Text word = new Text();
    public void map(Text key, Text value, Context context) throws IOException, InterruptedException
    {
        StringTokenizer itr = new StringTokenizer(value.toString(),",");
        while (itr.hasMoreTokens())
        {
            word.set(itr.nextToken());
            context.write(key, word);
        }
    }
}

package mavenKris;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: kshk
 * Date: 11/27/13
 * Time: 2:29 PM
 * To change this template use File | Settings | File Templates.
 */
public class AllTranslationsReducer extends Reducer<Text, Text, Text, Text> {
    private Text result = new Text();
    @Override
    protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
        String translations = "";
        for (Text val : values) {
            translations += "|" + val.toString();
        }
        result.set(translations);
        context.write(key, result);
    }
}

主。。。

package mavenKris;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: kshk
 * Date: 11/27/13
 * Time: 2:30 PM
 * To change this template use File | Settings | File Templates.
 */
public class Dictionary {
    public static void main(String[] args) throws Exception
    {
        Configuration conf = new Configuration();
        Job job = new Job(conf, "dictionary");
        job.setJarByClass(Dictionary.class);
        job.setMapperClass(WordMapper.class);
        job.setReducerClass(AllTranslationsReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        job.setInputFormatClass(KeyValueTextInputFormat.class);
        job.setOutputFormatClass(TextOutputFormat.class);
        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));
        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0 : 1);
    }
}

pom.xml就是这样的

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>mavenKris</groupId>
  <artifactId>mavenKris</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>mavenKris</name>
  <url>http://maven.apache.org</url>
    <repositories>
        <repository>
            <id>anorak-releases</id>
            <url>http://ip-10-40-3-96.cloud.trendinglines.co.uk:8081/nexus/content/repositories/releases/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>atlassian-releases</id>
            <url>http://repository.opencastproject.org/nexus/content/repositories/atlassian/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>central</id>
            <name>Maven Central</name>
            <url>http://repo1.maven.org/maven2/</url>
        </repository>
    </repositories>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
      <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-core</artifactId>
          <version>1.0.3-gphd-1.2.0.0</version>
          <scope>provided</scope>
      </dependency>
  </dependencies>

</project>

我正在使用hadoop的greenplum发行版,现在..当我运行上面的项目时,我得到这个错误。。。。

/usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7551 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration
    at mavenKris.Dictionary.main(Dictionary.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more

Process finished with exit code 1

有什么想法吗?
更新:
如果我从命令行中指定了路径类路径,它称为dictionary类,但给出了错误,那么在我的ide上一定有一些设置没有在运行时指定hadoop核心的类路径。。。。。

[kshk@localhost mavenKris]$ /usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7537 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar:/home/kshk/.m2/repository/org/apache/hadoop/hadoop-core/1.0.3-gphd-1.2.0.0/hadoop-core-1.0.3-gphd-1.2.0.0.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:143)
    at mavenKris.Dictionary.main(Dictionary.java:25)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more
[kshk@localhost mavenKris]$

更新2:
将路径添加到commons-logging-1.0.3.jar之后。。。。。。。。。。

[kshk@localhost repository]$ /usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7537 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar:/home/kshk/.m2/repository/org/apache/hadoop/hadoop-core/1.0.3-gphd-1.2.0.0/hadoop-core-1.0.3-gphd-1.2.0.0.jar:/home/kshk/.m2/repository/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:37)
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<clinit>(DefaultMetricsSystem.java:34)
    at org.apache.hadoop.security.UgiInstrumentation.create(UgiInstrumentation.java:51)
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:216)
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184)
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236)
    at org.apache.hadoop.security.KerberosName.<clinit>(KerberosName.java:79)
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:209)
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184)
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236)
    at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:466)
    at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:452)
    at org.apache.hadoop.mapreduce.JobContext.<init>(JobContext.java:80)
    at org.apache.hadoop.mapreduce.Job.<init>(Job.java:50)
    at org.apache.hadoop.mapreduce.Job.<init>(Job.java:54)
    at mavenKris.Dictionary.main(Dictionary.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.Configuration
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 21 more

更新3:
添加:/home/kshk/.m2/repository/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar到路径。。。。

[kshk@localhost repository]$ /usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7537 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar:/home/kshk/.m2/repository/org/apache/hadoop/hadoop-core/1.0.3-gphd-1.2.0.0/hadoop-core-1.0.3-gphd-1.2.0.0.jar:/home/kshk/.m2/repository/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar:/home/kshk/.m2/repository/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
    at org.apache.hadoop.metrics2.lib.MetricMutableStat.<init>(MetricMutableStat.java:59)
    at org.apache.hadoop.metrics2.impl.MetricsSystemImpl.<init>(MetricsSystemImpl.java:75)
    at org.apache.hadoop.metrics2.impl.MetricsSystemImpl.<init>(MetricsSystemImpl.java:120)
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:37)
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<clinit>(DefaultMetricsSystem.java:34)
    at org.apache.hadoop.security.UgiInstrumentation.create(UgiInstrumentation.java:51)
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:216)
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184)
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236)
    at org.apache.hadoop.security.KerberosName.<clinit>(KerberosName.java:79)
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:209)
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184)
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236)
    at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:466)
    at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:452)
    at org.apache.hadoop.mapreduce.JobContext.<init>(JobContext.java:80)
    at org.apache.hadoop.mapreduce.Job.<init>(Job.java:50)
    at org.apache.hadoop.mapreduce.Job.<init>(Job.java:54)
    at mavenKris.Dictionary.main(Dictionary.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 24 more

更新4:
将:/home/kshk/.m2/repository/commons-lang/commons-lang/2.1/commons-lang-2.1.jar添加到类路径

[kshk@localhost tmp]$ /usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7537 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar:/home/kshk/.m2/repository/org/apache/hadoop/hadoop-core/1.0.3-gphd-1.2.0.0/hadoop-core-1.0.3-gphd-1.2.0.0.jar:/home/kshk/.m2/repository/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar:/home/kshk/.m2/repository/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar:/home/kshk/.m2/repository/commons-lang/commons-lang/2.1/commons-lang-2.1.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at mavenKris.Dictionary.main(Dictionary.java:37)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
[kshk@localhost tmp]$

编辑:
intellij中的库jar

6ovsh4lw

6ovsh4lw1#

由于您是从ide运行它,因此应首先将pom更改为:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>mavenKris</groupId>
    <artifactId>mavenKris</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>mavenKris</name>
    <url>http://maven.apache.org</url>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>anorak-releases</id>
            <url>http://ip-10-40-3-96.cloud.trendinglines.co.uk:8081/nexus/content/repositories/releases/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>atlassian-releases</id>
            <url>http://repository.opencastproject.org/nexus/content/repositories/atlassian/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>central</id>
            <name>Maven Central</name>
            <url>http://repo1.maven.org/maven2/</url>
        </repository>
    </repositories>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>1.0.3-gphd-1.2.0.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

</project>

我假设anorak发行版是本地mvn存储库,而hadoop内核就在那里。检查它是否在那里,因为它对我不起作用,所以我必须:

<dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-core</artifactId>
        <version>0.20.2</version>
    </dependency>

而不是让它工作。
右键单击intelij中的pom文件并选择“synchronizepom”以导入正确的libs。然后从ide启动程序。
在此命令行之后,如下所示:
/usr/lib/jvm/java-6-sun-1.6.0.26/bin/java-didea.launcher.port=7533-didea.launcher.bin.path=/opt/instalations/idea-iu-123.169/bin-dfile.encoding=utf-8-classpath/日本/jr/lib////jj///java-6-susu1-1.6.6.0.26/jre//jre//jce.jar////usr///////////////////////////////////////jr////////j/////java-6-su1.6.6.6.6.0.26//jre////////////jr/////////////////////////////////////////////////////////////////////////////////////////////////1/java-6-sun-1.6.0.26版本/日本/jr/lib/lib////////jr//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////1.6.0.26/jre/lib/ext/localedata.jar:/work/elearning/reactive\u scala/hw2/untitled/mavenkris/target/classes:/root/.m2/repository/org/apache/hadoop/hadoop-core/0.20.2.jar:/root/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/root/.m2/repository/xmlenc/0.52/xmlenc-0.52.jar:/root/.m2/repository/commons-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1.jar:/root/.m2/repository/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar:/root/.m2/repository/commons-codec/commons-codec/1.3.jar:/root/.m2/repository/commons-net/commons-net/1.4.1/commons-net-1.4.jar:/root/.m2/repository/oro/oro/2.0.8.jar:/root/.m2/repository/org/mortbay/jetty/jetty/6.1.14/jetty-6.1.14.jar:/root/.m2/repository/org/mortbay/jetty/jetty-util/6.1.14/jetty-util-6.1.14.jar:/root/.m2/repository/org/mortbay/jetty/servlet-api-2.5/6.1.14.jar:/root/.m2/repository/tomcat/jasper runtime/5.5.12/jasper-runtime-5.5.12.jar:/root/.m2/repository/tomcat/jasper compiler/5.5.12/jasper-compiler-5.5.12.jar:/root/.m2/repository/org/mortbay/jetty/jsp-api-2.1/6.1.14/jsp-api-2.1-6.1.14.jar:/root/.m2/repository/org/mortbay/jetty/jsp-2.1/6.1.14.jar:/root/.m2/repository/org/eclipse/jdt/core/3.1.1/core-3.1.1.jar:/root/.m2/repository/ant/ant/1.6.5.jar:/root/.m2/repository/commons el/commons el/1.0/commons-el-1.0.jar:/root/。m2/repository/net/java/dev/jets3t/jets3t/0.7.1/jets3t-0.7.1.jar:/root/.m2/repository/net/sf/kosmosfs/kfs/0.3/kfs-0.3.jar:/root/.m2/repository/hsqldb/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar:/opt/instalations/idea-iu-123.169/lib/idea_rt.jar com.intellij.rt.execution.application.appmain mavenkris.dictionary.txt output.txt

相关问题