无法用maven-assembly-plugin设置最终的jar名称

这就是我configurationmaven-assembly-plugin

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <configuration> <finalName>myapp</finalName> <archive> <manifest> <mainClass>com.myapp.Main</mainClass> </manifest> </archive> <!-- <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> --> </configuration> </plugin> 

我期望最终的jar文件应该是myapp.jar但它最终与myapp-jar-with-dependencies.jar

你能告诉我如何configuration从最终的名称中排除"jar-with-dependencies"吗?

您可以指定finalName属性来为jar指定所需的名称,并指定appendAssemblyId应该为false,以避免jar-with-dependencies后缀。 下面的configuration将输出一个名为test.jar

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.4</version> <configuration> <finalName>test</finalName> <archive> <manifest> <mainClass>com.myapp.Main</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <appendAssemblyId>false</appendAssemblyId> </configuration> </plugin>