我尝试在spring-graals中运行aws函数示例,'java‘版本运行良好,但当我测试’原生‘版本时,我在控制台中看到以下错误。
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-native版本为0.70.BUILD-SNAPSHOT.jar
快照版本为3.1.0- spring-cloud-function
pom文件可以是found here。
此外,在亚马逊网络服务控制台中,我只能使用类型为FunctionInvoker的处理程序进行测试,而不能使用SpringBootApiGatewayRequestHandler。
发布于 2020-12-14 02:51:02
需要添加以下依赖项才能成功编译本机映像。
<!-- 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>https://stackoverflow.com/questions/63801534
复制相似问题