Java 的 AWS 开发工具包入门

Getting started with AWS SDK for Java

我对 Java 的 AWS SDK 还很陌生。我正在尝试按照此处的文档 (https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html#get-started-projectsetup)

开始使用适用于 Java 2.x 的 AWS SDK

但是当我尝试使用以下命令创建此处提到的项目时

mvn -B archetype:generate \-DarchetypeGroupId=org.apache.maven.archetypes \-DgroupId=com.example.myapp \-DartifactId=myapp

我遇到一个错误:

PS C:\Users\robert\Desktop> mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.example.myapp -DartifactId=myapp
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.100 s
[INFO] Finished at: 2021-08-09T12:26:24-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\robert\Desktop). Please verify you invoked Maven from 
the correct directory. -> [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/MissingProjectExceptio

如何创建maven项目并开始使用aws sdk?

命令中有 / 字符吗?如果是这样,你需要使用这个命令:

   mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.example.myapp -DartifactId=myapp

我正在使用 JDK 1.8,此命令成功。

在 Powershell 中,您不能在命令行参数中使用句点(点或句号)。该页面上的说明缺少此信息,并假设是类 Unix 环境或 cmd 环境。你应该 运行:

mvn -B archetype:generate "-DarchetypeGroupId=org.apache.maven.archetypes" "-DgroupId=com.example.myapp" -DartifactId=myapp