什么是适用于 Lambda 的 AWS SDK V2 Maven 库? [英] What's the AWS SDK V2 Maven lib for Lambda?

查看:27
本文介绍了什么是适用于 Lambda 的 AWS SDK V2 Maven 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新我的项目,以便通过使用 bom 配置来使用 SDK v2.我已经更新了我的 pom 文件,但现在找不到 RequestHandlerContext.这是我的 Maven 配置文件

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>

还有我之前的配置

<dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-lambda-java-core</artifactId>
            <version>1.2.0</version>
        </dependency>

似乎无法找到我应该导入的内容以包含丢失的类.还是在V2中,有不同的签名?

Can't seems to find what I should import to have the missing classes. Or in the V2, there is a different signature ?

这是我的课:

public class Cron implements RequestHandler<Object, Object> {

    public Object handleRequest(final Object input, final Context context) {

感谢您的指点.

C.C.

推荐答案

似乎您的类路径中仍然需要同时拥有 SDK v1 和 SDK v2.

It seems like you still have to have both SDK v1 and SDK v2 on your classpath.

例如,查看 Lambda Java 文档 您可以看到所有导入仍然以 com.amazonaws (SDK v1) 开头,而不是 software.amazon (SDK v2).

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).

他们列出的示例之一是 blank-java 他们将其描述为具有事件库、高级日志记录配置以及调用 Lambda API 以检索帐户设置的适用于 Java 2.x 的 AWS 开发工具包的 Java 函数"

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"

如果您查看该示例应用程序的 pom.xml 你会看到 com.amazonawssoftware.amazon 包混合在一起.

If you look at that sample application's pom.xml you'll see com.amazonaws and software.amazon packages mixed together.

Lambda 处理程序.

所以要么他们没有将所有内容都移植到 SDK v2,要么他们仍然希望您使用 SDK v1 中的接口 - 然后可以从 SDK v2 中使用更多功能代码(非接口代码).

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.

这篇关于什么是适用于 Lambda 的 AWS SDK V2 Maven 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆