调用 Lambda 函数时出现 ClassNotFoundException

ClassNotFoundException when Lambda Function gets invoced

将 Spring Cloud Function 上传到 AWS Lambda 并对其进行测试后,我得到:

Class not found: example.Hello: java.lang.ClassNotFoundException
java.lang.ClassNotFoundException: example.Hello
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)

但是我的包中没有任何 Hello class 并且项目中没有使用字符串“Hello”(我使用了 Eclipse 搜索)。

如何找到根本原因?

您需要更新Lambda's Function Code

In Lambda, under Function Code, where you specify Handler Info, instead of 'example.Hello', you need to replace that with your own Request Handler.

This link shows how you would do that in AWS Lambda Setup instruction 9. In this example, handler info is 'com.amazon.asksdk.helloworld.HelloWorldSpeechletRequestStreamHandler' and that's what you would be replacing instead of 'example.Hello'