简体   繁体   English

WordCount示例在Eclipse中运行,但不在终端中运行

[英]WordCount example runs in Eclipse, but not in terminal

I tried running first of the WordCount examples and it works in Eclipse (I have Windows 7 OS), but not in shell, using the command: 我尝试运行第一个WordCount示例,并使用以下命令在Eclipse(我有Windows 7 OS)中运行,但在shell中不能运行:

mvn compile exec:java -Dexec.mainClass=com.google.cloud.dataflow.examples.MinimalWordCount

I have installed Maven and configured JAVA_HOME and Path variables and so on, however, I'm not sure what I must have missed. 我已经安装了Maven并配置了JAVA_HOME和Path变量,等等,但是,我不确定我一定错过了什么。 This is the output: 这是输出:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutorial 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Tutorial ---
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Java\eclipse-jee-luna-SR2-win32-x8
6_64\eclipse\workspace\Tutorial\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ Tutorial --
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ Tutorial ---
[WARNING]
java.lang.ClassNotFoundException: com.google.cloud.dataflow.examples.MinimalWord
Count
    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:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281)
    at java.lang.Thread.run(Thread.java:744)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.011 s
[INFO] Finished at: 2015-11-03T01:11:57+01:00
[INFO] Final Memory: 17M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java 
(default-cli) on project Tutorial: An exception occured while executing the Java 
class. com.google.cloud.dataflow.examples.MinimalWordCount -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please
read the following articles:
[ERROR] [Help 1]    http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception-

I am in the dark about how to proceed and would very much appreciate ideas of where to look next and other things to try. 我对如何进行工作一无所知,非常感谢下一步的想法和其他尝试的想法。

Thanks! 谢谢!

You may have run into an issue with the documentation. 您可能遇到了文档问题。

The command line you are using should work if you have cloned GoogleCloudPlatform/DataflowJavaSDK-examples . 如果您克隆了GoogleCloudPlatform / DataflowJavaSDK-examples,则您正在使用的命令行应该可以使用。 The mention of the particular repo to clone is way back in " getting started ", not at all obvious if you head straight to WordCount Example Pipeline . 提到要克隆的特定存储库可以追溯到“ 入门 ”,如果直接进入WordCount Example Pipeline则一点都不明显。

But if you generated the project from the Cloud Dataflow Plugin for Eclipse (or via a Maven archetype ) then the examples are placed into your Java package. 但是,如果您是从EclipseCloud Dataflow插件 (或通过Maven原型 )生成项目的,则示例将放入Java包中。 So instead of com.google.cloud.dataflow.examples.MinimalWordCount you will use the name my.java.project.MinimalWordCount , where my.java.project is whatever package name you chose when you created the project. 因此,将使用名称my.java.project.MinimalWordCount而不是com.google.cloud.dataflow.examples.MinimalWordCount ,其中my.java.project是创建项目时选择的任何包名称。

Or if you have cloned the SDK itself from GoogleCloudPlatform/DataflowJavaSDK then you will need to add -pl examples to your command line. 或者,如果您已从GoogleCloudPlatform / DataflowJavaSDK克隆了SDK本身,则需要在命令行中添加-pl examples This is because the SDK's repository is factored into maven modules; 这是因为SDK的存储库已分解为Maven模块。 this flag instructs maven to run in the context of the examples module. 该标志指示maven在examples模块的上下文中运行。

如果您有一个多模块Maven项目(DataflowJavaSDK,而不是DataflowJavaSDK-examples),则可以在顶层目录中执行mvn compile ,然后在cd插入examples ,然后在其中mvn exec:java -Dexec.mainClass=...命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM