设置打包在 WAR 中的 JAR 名称



我创建了一个WAR项目和一个JAR项目,设置得像JAR项目的WAR依赖项一样,我在JAR项目pom文件中使用了标签<finalName>来设置打包WAR时文件名。 我运行 maven 安装并检查所有名称是否正确。jar 采用项目的名称,而不是<finalName>标记中的名称。 为什么?如何设置罐子的名称?我使用maven-war-plugin version 3.0.0.

预期结果:包含网络服务的AOL.war.jar

实际结果:包含 JarProject-3.0.0 的 AOL.war.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>WarProject</groupId>
<artifactId>WarProject</artifactId>
<version>3.0.0</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>b7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>net.sf.flexjson</groupId>
<artifactId>flexjson</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7-dep</version>
</dependency>
<dependency>
<groupId>mate</groupId>
<artifactId>captcha</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>mate</groupId>
<artifactId>sifw</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>mate</groupId>
<artifactId>sifw-devel</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>mate</groupId>
<artifactId>sifw-upload</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>mate</groupId>
<artifactId>sifw-velocity</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>jdbc</artifactId>
<version>6</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>WarProject</groupId>
<artifactId>WarProject</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<build>
<!--sourceDirectory>src</sourceDirectory -->
<finalName>AOL</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<wtpversion>2.0</wtpversion>
<wtpContextName>WEBAOL</wtpContextName>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src</source>
<source>src_mega</source>
<source>src_ws</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<packagingExcludes>WEB-INF/classes/**/DocsServlet.class</packagingExcludes>
<packagingExcludes>META-INF/context.xml</packagingExcludes>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ProjectParent</groupId>
<artifactId>ProjectParent</artifactId>
<version>3.0.0</version>
</parent>
<artifactId>JarProject</artifactId>
<name>JarProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>webservices</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
<executions>
<execution>
<id>delete-files</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>youbanking-ws</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>wsdl/GestionePratica</wsdlDirectory>
<keep>true</keep>
<sourceDestDir>src/main/java</sourceDestDir>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
jaxws-maven-plugin
</artifactId>
<versionRange>
[1.12,)
</versionRange>
<goals>
<goal>wsimport</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-clean-plugin
</artifactId>
<versionRange>[2.4.1,)</versionRange>
<goals>
<goal>clean</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

AFAIK 属性 finalName 仅更改目标目录中创建的 jar 的名称,而不更改本地或远程存储库中创建 jar 的名称。你的战争版本可能会从本地存储库获取你的jar工件,所以finalName不会有任何影响。

如果要更改工件的名称,请在生成 pom 之前更改 pom 中的坐标(groupId、工件 Id、版本、分类器(。

相关内容

  • 没有找到相关文章

最新更新