IntelliJ IDEA Config cant find AWS Lambda Handler in Default 'helloworld' Application

Dav*_*vid 8 java intellij-idea aws-lambda aws-sam-cli aws-toolkit

When setting the debug configurations for the default IntelliJ IDEA Java helloworld application (created upon making a new AWS Lambda project) the following response is shown:

Error: Cannot find handler 'helloworld.App::handleRequest' in project."

To fix this I've tried editing 'Handler' element inside template.yaml to include a filepath, though there had been no success.

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: HelloWorldFunction
      Handler: helloworld.App::handleRequest
Run Code Online (Sandbox Code Playgroud)

I noticed the Python AWS Lambda helloworld project (within the PyCharm counterpart) required me to change the root project folder (allowing the handler to be found), however, I cant seem to achieve this with the Java counterpart within IntelliJ.

The default project file structure is as follows:

bash
??? README.mdH
??? HelloWorldFunction 
?   ??? pom.xml    
?   ??? src
?       ??? main
?       ?   ??? java
?       ?       ??? helloworld
?       ?           ??? App.java
?       ?           ??? GatewayResponse.java  
?       ??? test  
?           ??? java
?               ??? helloworld
?                   ??? AppTest.java
??? template.yaml
Run Code Online (Sandbox Code Playgroud)

The relevant section of the template.yaml file contains:

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: HelloWorldFunction
      Handler: helloworld.App::handleRequest
      Runtime: java8
      Events:
        HelloWorld:
          Type: Api
          Properties:
            Path: /hello
            Method: get
Run Code Online (Sandbox Code Playgroud)

The App.java file contains the class

public class App implements RequestHandler<Object, Object> {
    ...
}
Run Code Online (Sandbox Code Playgroud)

I would like the debug configuration to point to the correct Handler ( being "helloworld.App::handleRequest") so I can run the project on my local machine.

pri*_*iit 5

在项目文件上,右键单击,HelloWorldFunction然后找到Mark directory as并选择Source Root。那应该解决您的问题。

在此处输入图片说明