Setup maven project
Install the CDK4J maven plugin and add the dependencies below to your pom.xml to prepare a Spring Cloud Function for deployment as an AWS Lambda.
aws-cdk-lib dependency is declared with provided scope because the AWS CDK runtime is supplied by the AWS Serverless Java Container.<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-adapter-aws</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>aws-cdk-lib</artifactId>
<scope>provided</scope>
</dependency>The spring-cloud-function-adapter-aws dependency adapts your Spring Cloud Function beans (Function, Consumer, Supplier) to the AWS Lambda execution model. It automatically transforms incoming AWS event payloads—such as API Gateway requests, SQS messages, SNS notifications, and S3 events—into the Java types your functions expect, and it serializes the function return values back into the AWS-compatible format so Lambda can forward the response to the caller.
The aws-cdk-lib dependency provides the Java CDK constructs and APIs you use to define the infrastructure that will host your Lambda ([stacks](/reference/cloud-development-kit/stack/, Lambda functions, IAM roles, event sources, etc.). During synthesis the CDK produces a cloud assembly that CDK4J/your build will deploy, but the library itself is not required at Lambda runtime when the AWS Serverless Java Container is providing the execution environment.