java - maven 程序集插件不包括我在构建的 jar 中的类

标签 java maven amazon-web-services intellij-idea lambda

下面引用的任何代码都来自项目 here

对于 AWS Lambda,我一直在尝试根据此处定义的 maven 配置创建一个 jar 文件。

<?xml version="1.0" encoding="UTF-8"?>
  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.quodlibet</groupId>
<artifactId>HelloLambda</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-lambda-java-core</artifactId>
        <version>1.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.0</version>
    </dependency>
</dependencies>
<build>

  <plugins>
  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
        </configuration>
        <executions>
            <execution>
                <id>assemble-all</id>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
 </plugins>



当我尝试构建胖 JAR 并将其上传到 AWS Lambda 控制台时,我看到了错误

以下包 be.quodlibet.hellolambda 没有添加到 jar 中,导致
"errorMessage": "Class not found: be.quodlibet.hellolambda.helloHandler",
"errorType": "java.lang.ClassNotFoundException"

最佳答案

正如@khmarbaise 在评论中所说,请确保您运行“mvn clean package”而不是“mvn clean assembly:single”。

关于java - maven 程序集插件不包括我在构建的 jar 中的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47778826/

相关文章:

java - 如何在java中打印数组中所有数字的总和?

Java:引用类型?

java - Elastic Beanstalk返回错误-Gradle/Java应用程序

amazon-web-services - AWS Fargate 的最长运行时间为 120 秒?

java - 发生错误时使用 JAX-WS 跟踪 XML 请求/响应

java - 为什么我的 Spring OAuth2 服务器无法使用 SSL 自签名 ssl?

java - 使用gradle将Scala集成到Java中的现有项目中

maven - 让 IntelliJ IDEA 对 maven 项目使用不同的 pom 文件

java - KIE Drools Workbench 无法解决 Maven 依赖关系

ssl - 我网站的 AWS 负载均衡器和 ssl 证书