我尝试首先运行WordCount examples并且它在Eclipse(我有Windows 7操作系统)中运行,但不在shell中,使用命令:
mvn compile exec:java -Dexec.mainClass=com.google.cloud.dataflow.examples.MinimalWordCount
我已经安装了Maven并配置了JAVA_HOME和Path变量等等,但是,我不确定我一定错过了什么。这是输出:
[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-
我对如何继续下去并且非常欣赏下一步要去哪里以及尝试其他事情的想法。
谢谢!
答案 0 :(得分:1)
您可能遇到了文档问题。
如果您克隆了GoogleCloudPlatform/DataflowJavaSDK-examples,那么您使用的命令行应该可以正常工作。提及克隆的特定回购是回到" getting started",如果你直接前往WordCount Example Pipeline,一点也不明显。
但是如果您从Cloud Dataflow Plugin for Eclipse(或通过Maven archetype)生成项目,则示例将放入您的Java包中。因此,您将使用名称com.google.cloud.dataflow.examples.MinimalWordCount
代替my.java.project.MinimalWordCount
,其中my.java.project
是您在创建项目时选择的任何包名称。
或者如果您从GoogleCloudPlatform/DataflowJavaSDK克隆了SDK本身,则需要在命令行中添加-pl examples
。这是因为SDK的存储库被分解为maven模块;此标志指示maven在examples
模块的上下文中运行。
答案 1 :(得分:0)
如果你有一个多模块maven项目(DataflowJavaSDK,而不是DataflowJavaSDK-examples),你可以在顶层目录中mvn compile
,然后cd
到examples
然后发出那里有mvn exec:java -Dexec.mainClass=...
命令。