1

重现步骤:

  1. mn create-app example.micronaut.complete --features aws-api-gateway-graal
  2. 添加依赖实现 'com.amazonaws:aws-java-sdk-sns:1.11.656'
  3. 修改 mn-cli 自动创建的 index() 函数
@Get("/ping")
    public String index() { //automatically created by mn-cli
        AmazonSNS sns = AmazonSNSClient.builder() //Create SNS client
                .withRegion("ap-south-1").build(); //Specify Region
        return "{\"pong\":true, \"graal\": true}";// to check whether function is working
    }
  1. ./sam-local.sh
  2. http://localhost:3000/ping

我收到以下错误,然后函数超时:

使用 requestId [21a6b1d0-7697-12b0-f4d8-d15e16954a4c] 调用失败:org.apache.commons.logging.LogFactoryjava.lang.NoClassDefFoundError:org.apache.commons.logging.LogFactory 中的 org.apache.commons.logging.LogFactory。 org.apache.commons.logging.LogFactory.(LogFactory.java:1674) 上的类 $(LogFactory.java:1021)

4

1 回答 1

0

只需将commons-logging依赖项添加到您的 pom.xml 或 build.gradle:

/build.gradle:
dependencies {
   .
   ..
   compile 'commons-logging:commons-logging:1.2'
} 
/pom.xml:
...
<dependencies>
   .
   ..
   <dependency>
     <groupId>commons-logging</groupId>
     <artifactId>commons-logging</artifactId>
     <version>1.2</version>
   </dependency>

</dependencies> 
于 2021-02-03T00:02:45.573 回答