Issue
I'm trying to update my project in order to use SDK v2 by using bom configuration.
I have updated my pom file but now RequestHandler
and Context
can't be found.
Here is my maven config file
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>lambda</artifactId>
</dependency>
</dependencies>
And my config before which was working
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.2.0</version>
</dependency>
Can't seems to find what I should import to have the missing classes. Or in the V2, there is a different signature ?
This is my class:
public class Cron implements RequestHandler<Object, Object> {
public Object handleRequest(final Object input, final Context context) {
Thanks for any pointer.
C.C.
Solution
It seems like you still have to have both SDK v1 and SDK v2 on your classpath.
For example, looking at the Lambda Java documentation you can see that all imports still start with com.amazonaws
(SDK v1) and not software.amazon
(SDK v2).
One of the examples they list there is blank-java which they describe as "A Java function with the events library, advanced logging configuration, and the AWS SDK for Java 2.x that calls the Lambda API to retrieve account settings"
If you look at that sample application's pom.xml you'll see com.amazonaws
and software.amazon
packages mixed together.
Similarly for the Lambda handler.
So either they haven't ported everything to SDK v2, or they still want you to use the interfaces from SDK v1 - and then more functional code (non interface code) can be used from SDK v2.
Answered By - dutoitns
Answer Checked By - Gilberto Lyons (JavaFixing Admin)