【问题标题】:Attach the snapshot version name with the JAR file使用 JAR 文件附加快照版本名称
【发布时间】:2023-03-08 23:23:02
【问题描述】:

我使用以下 pom.xml 文件运行 Hadoop 应用程序。该文件包含用于创建 JAR 文件和所需依赖项的所有信息。文件如下:

<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>com.test.hadoop.wordcount</groupId>
    <artifactId>wordcount</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>wordcount</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- Hadoop -->
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.test.hadoop.wordcount.WordCount</mainClass>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
        </plugin>
        </plugins>
    </build>
</project>

当我运行应用程序时,它会在该位置创建 JAR 文件 wordcount.jar

但是,我想附上带有 JAR 名称的快照版本,即。 wordcount-0.0.1-SNAPSHOT.jar.

我如何做到这一点?我对快照版本控制不是很了解。我现在提供了更新的pom.xml 文件。

更新

我添加了阴影插件,但这并不能解决问题。此外,目标目录中没有 JAR。

【问题讨论】:

  • 第一步是把&lt;version&gt;RELEASE&lt;/version&gt;去掉,换成你想用的真实版本...

标签: java maven jar pom.xml


【解决方案1】:

Intellij w/ Maven 在目标文件夹下生成版本化 JAR

注意:由于您没有使用 Shade 插件,因此您的 JAR 不应包含您可能需要的依赖项

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2013-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多