0

我正在尝试在 spring-graals 中运行 aws 函数示例,“java”版本工作正常,但是当我测试“native”版本时,我在控制台中看到以下错误。

Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.cloud.function.adapter.aws.CustomRuntimeInitializer
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:445)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:427)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:272)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:253)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
    at com.example.demo.serverless.ServerlessApplication.main(ServerlessApplication.java:22)
Caused by: java.lang.NoSuchMethodException: org.springframework.cloud.function.adapter.aws.CustomRuntimeInitializer.<init>()
    at java.lang.Class.getConstructor0(DynamicHub.java:3082)
    at java.lang.Class.getDeclaredConstructor(DynamicHub.java:2178)
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:440)
    ... 7 more

该示例将步骤记录到 output.txt 中,我在其中看到以下几行。

WARNING: Could not register reflection metadata for org.springframework.cloud.function.adapter.aws.CustomRuntimeInitializer. Reason: java.lang.NoClassDefFoundError: org/springframework/cloud/function/web/source/DestinationResolver.

版本是spring-graals-native0.70.BUILD-SNAPSHOT.jar

版本是spring-cloud-function3.1.0-SNAPSHOT

pom 文件可以在这里找到

此外,在 aws 控制台中,我只能使用类型的处理程序进行测试,FunctionInvoker而不能使用SpringBootApiGatewayRequestHandler.

4

1 回答 1

0

需要添加以下依赖项才能成功编译原生映像。

<!-- Required by DestinationResolver -->
       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

<!-- "spring-cloud-function-adapter-aws" coupled with webFlux-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-function-web</artifactId>
        </dependency>
于 2020-12-13T18:51:02.190 回答