我正在使用 STS 4 ( https://spring.io/tools ) 并添加了 Eclipse AWS 工具包 ( https://marketplace.eclipse.org/content/aws-toolkit-eclipse )。
重启 STS 后,我们可以看到一切正常。
现在我已经在本地安装了 AWS SAM CLI
并配置了我们有 sam.exe 的路径
我在本地安装了 Java 8 和 Python 2.7 和 3.6 以及 docker。
现在创建了 AWS Java 无服务器项目 maven install 并尝试运行 sam local
更新 :
当我尝试运行 SAM-CLI 时,它的工作和返回响应。
模板.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
并运行配置
**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] ------------------------------------------------------------------------
错误日志:
无法启动 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!
我想知道是否有人解决了这个问题?