gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 07:49:20 25 4
gpt4 key购买 nike

我尝试先运行 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-

我对如何继续一无所知,并且非常感谢关于下一步该去哪里以及其他可以尝试的事情的想法。

谢谢!

最佳答案

您可能遇到了文档问题。

如果您已克隆 GoogleCloudPlatform/DataflowJavaSDK-examples,则您正在使用的命令行应该可以工作。 。要克隆的特定存储库的提及早在“getting started”中,如果您直接前往WordCount Example Pipeline,则一点也不明显。 .

但是如果您从 Cloud Dataflow Plugin for Eclipse 生成项目(或通过 Maven archetype )然后将示例放入您的 Java 包中。因此,您将使用名称 my.java.project.MinimalWordCount,而不是 com.google.cloud.dataflow.examples.MinimalWordCount,其中 my.java.project 是您在创建项目时选择的包名称。

或者,如果您已从 GoogleCloudPlatform/DataflowJavaSDK 克隆了 SDK 本身那么您需要将 -pl Examples 添加到命令行中。这是因为 SDK 的存储库被分解为 Maven 模块;该标志指示 maven 在 examples 模块的上下文中运行。

关于java - WordCount 示例在 Eclipse 中运行,但不在终端中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33489630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com