gpt4 book ai didi

amazon-web-services - 如何在 Eclipse 和 Window 10 上配置 AWS SAM

转载 作者:行者123 更新时间:2023-12-02 00:56:27 33 4
gpt4 key购买 nike

我正在使用 STS 4 ( https://spring.io/tools ) 并添加了 Eclipse AWS 工具包 ( https://marketplace.eclipse.org/content/aws-toolkit-eclipse ) 。

重新启动 STS 后,我们可以看到一切都很好。

enter image description here

现在我已经在本地安装了 AWS SAM CLI

enter image description here

并配置了我们有 sam.exe 的路径

enter image description here

I have Java 8 and Python 2.7 and 3.6 and docker installed in my local.



现在创建了 AWS Java 无服务器项目 maven install 并尝试在本地运行 sam
  • https://aws.amazon.com/blogs/developer/aws-toolkit-for-eclipse-locally-debug-your-lambda-functions-and-api-gateway/

  • enter image description here

    更新:

    当我尝试运行 SAM-CLI 时,它的工作和返回响应。

    enter image description here

    模板.yaml
    AWSTemplateFormatVersion : '2010-09-09'
    Transform: AWS::Serverless-2016-10-31
    Description: AWS Lambda Sample Project

    Resources:

    Products:
    Type: AWS::Serverless::Function
    Properties:
    Handler: com.example.handler.LambdaHandler
    CodeUri: ./target/lambda-project-1.0-SNAPSHOT.jar
    Runtime: java8
    Timeout: 300
    Environment:
    Variables:
    ENVIRONMENT: "test"
    Events:
    ListProducts:
    Type: Api
    Properties:
    Path: /lambda
    Method: post

    并运行配置

    enter image description here
    **Maven build :**


    [INFO] Scanning for projects...
    [INFO]
    [INFO] ---------------------< com.example:lambda-project >---------------------
    [INFO] Building lambda-project 1.0-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO]
    [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lambda-project ---
    [INFO] Deleting C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lambda-project ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 2 resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ lambda-project ---
    [INFO] Changes detected - recompiling the module!
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 6 source files to C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\classes
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ lambda-project ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 2 resources
    [INFO]
    [INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ lambda-project ---
    [INFO] Changes detected - recompiling the module!
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 1 source file to C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\test-classes
    [INFO]
    [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ lambda-project ---
    [INFO] Surefire report directory: C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\surefire-reports

    -------------------------------------------------------
    T E S T S
    -------------------------------------------------------
    Running com.example.handler.LambdaHandlerTest
    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.291 sec

    Results :

    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

    [INFO]
    [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ lambda-project ---
    [INFO] Building jar: C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\lambda-project-1.0-SNAPSHOT.jar
    [INFO]
    [INFO] --- maven-shade-plugin:3.1.0:shade (default) @ lambda-project ---
    [INFO] Including com.amazonaws:aws-lambda-java-events:jar:2.0.2 in the shaded jar.
    [INFO] Including joda-time:joda-time:jar:2.6 in the shaded jar.
    [INFO] Including com.amazonaws:aws-lambda-java-core:jar:1.2.0 in the shaded jar.
    [INFO] Including com.typesafe:config:jar:1.3.1 in the shaded jar.
    [INFO] Including org.apache.logging.log4j:log4j-api:jar:2.5 in the shaded jar.
    [INFO] Including org.apache.logging.log4j:log4j-core:jar:2.5 in the shaded jar.
    [INFO] Including com.google.code.gson:gson:jar:2.8.2 in the shaded jar.
    [INFO] Replacing original artifact with shaded artifact.
    [INFO] Replacing C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\lambda-project-1.0-SNAPSHOT.jar with C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\lambda-project-1.0-SNAPSHOT-shaded.jar
    [INFO] Dependency-reduced POM written at: C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\dependency-reduced-pom.xml
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3.510 s
    [INFO] Finished at: 2018-12-25T21:27:10-06:00
    [INFO] ------------------------------------------------------------------------

    错误日志:

    Failed to launch SAM Local. com.amazonaws.eclipse.core.exceptions.AwsActionException



    日志:
    eclipse.buildId=4.0.2.201811300843-RELEASE
    java.version=1.8.0_191
    java.vendor=Oracle Corporation
    BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
    Framework arguments: -product org.springframework.boot.ide.branding.sts4
    Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4

    com.amazonaws.eclipse.lambda
    Error
    Tue Dec 25 21:21:52 CST 2018
    Failed to launch SAM Local.

    com.amazonaws.eclipse.core.exceptions.AwsActionException
    at com.amazonaws.eclipse.lambda.launching.SamLocalDelegate.launch(SamLocalDelegate.java:159)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:862)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:720)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1029)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:1243)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
    Caused by: java.lang.NullPointerException
    at com.amazonaws.eclipse.lambda.launching.SamLocalDelegate.launch(SamLocalDelegate.java:116)
    ... 5 more

    eclipse.buildId=4.0.2.201811300843-RELEASE
    java.version=1.8.0_191
    java.vendor=Oracle Corporation
    BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
    Framework arguments: -product org.springframework.boot.ide.branding.sts4
    Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4

    org.eclipse.m2e.logback.appender
    Warning
    Tue Dec 25 21:21:47 CST 2018
    Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!

    我想知道是否有人解决了这个问题?

    最佳答案

    有同样的问题。

    首先你应该打开命令行并运行
    where sam如果您发现该路径包含任何空格,例如,如果其路径中有“Program Files”,则卸载 samcli 并重新安装它。确保其路径不包含任何空格,例如:C:\Amazon\SAMCLI。当您完成安装 samcli 后,在 cmd 中重新运行之前的代码并复制路径并粘贴到 eclipse 中。

    其次,您应该通过创建配置文件来遵循 Dimman 的建议。您可以通过运行 awscli 来执行此操作
    aws configuration
    这将自动创建文件。保存并重新启动,一切都应该没问题。

    祝你好运。

    关于amazon-web-services - 如何在 Eclipse 和 Window 10 上配置 AWS SAM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53916879/

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