无法使用IoT java SDK编译代码

0

【以下的问题经过翻译处理】 我已成功创建了一个IoT设备,并能够通过Windows和Python SDK让它工作。然后,我想看看Java代码是如何工作的,因此我选择了Windows和Java SDK,并在此页面https://us-east-2.console.aws.amazon.com/iot/home?region=us-east-1#/connectdevice/上单击了下一步,并选择了我已经设置并在Python中工作的设备。

我点击下一步,并点击了下载Java SDK的链接。我解压了Java SDK并启动了Windows Power Shell。我解压了下载的SDK,更改了目录到它,运行了“Set-ExecutionPolicy-ExecutionPolicy Bypass-Scope Process”以更改执行策略,然后运行了start.ps1。 例子因错误而无法构建,错误如下:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.373 s 
[INFO] Finished at: 2022-04-28T15:29:22-07:00 
[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project aws-iot-device-sdk-java-samples: Could not resolve dependencies for project com.amazonaws:aws-iot-device-sdk-java-samples:jar:0.0.1-dev: Could not find artifact com.amazonaws:aws-iot-device-sdk-java:jar:0.0.1-dev in central (https://repo.maven.apache.org/maven2) -> 
[Help 1] 
[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/DependencyResolutionException

如何解决此问题?

profile picture
EXPERTE
gefragt vor 5 Monaten44 Aufrufe
1 Antwort
0

【以下的回答经过翻译处理】 从log来看,是在maven构建中没有找到以来包:com.amazonaws:aws-iot-device-sdk-java:jar:0.0.1-dev。 我们可以有2种方式来引入依赖包:

  1. 本地编译: 从GitHub获取aws-iot-device-sdk-java代码,并运行如下命令编译:
mvn install --% -Dgpg.skip=true -Dmaven.test.skip=true
在本地代码,来引入编译出来的jar文件。

2.在本地的pom文件中,引入maven center repo,下载依赖包。

<dependencies>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-iot-device-sdk-java</artifactId>
    <version>1.3.9</version>
  </dependency>
</dependencies>

完成编译后,运行命令,连接IoT core。

$ mvn exec:java -pl aws-iot-device-sdk-java-samples -Dexec.mainClass="com.amazonaws.services.iot.client.sample.pubSub.PublishSubscribeSample" -Dexec.args="-clientEndpoint <prefix>-ats.iot.<region>.amazonaws.com -clientId <unique client id> -certificateFile <certificate file> -privateKeyFile <private key file>"
profile picture
EXPERTE
beantwortet vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen