0

我已经在这个论坛上阅读了很多答案,所以希望我能问一些问题。最近我们迁移到 Tomcat 7,通常的程序是从 Nexus 存储库中获取一个 war 文件,将其粘贴到 Tomcat webapps 目录中,然后启动服务器并使用它。但是由于 Nexus 中的 war 文件工件名称是 my-app-war-1.0.war 在 tomcat 中的上下文路径,这不是预期的。我知道这可以通过 context.xml 进行配置,但我想知道是否有办法将## 添加到部署在 Nexus 中的工件名称中。

我尝试更改 @{project.build.finalName} 但它只更改目标目录中的工件名称,maven 部署插件仍然使用 artifactId,即“my-app-war”。所以 Nexus 中的工件最终成为 'my-app-war-1.0.war' 因为 maven 中的 artifactId 具有非常严格的结构,并且在那里不允许使用 ## 我想知道将 ## 添加到工件名称的正确方法是什么,因为我们很可能会考虑使用并行部署,所以我正在寻找启用此功能的方法。

我想我可以将同一个 war 文件的两个版本部署到 Nexus,其中一个的名称略有不同(使用##),但是重命名它并节省一些空间会更容易。我想知道当在 Tomcat 中实现并行命名功能时,是否有任何计划如何将## 添加到应用程序名称中。

4

2 回答 2

0

您可以<classifier>使用maven-war-plugin. 这样,您war将使用名称安装到存储库中${project.artifactId}-${project.version}-my-app-war.war

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <classifier>##my-app-war</classifier>
            </configuration>
        </plugin>
于 2013-09-19T11:47:42.393 回答
0

问题是,如果您包含在 Maven 版本中,Nexus 会返回以下错误##

Illegal character in fragment at index 103

您可以 <path>通过部署到 Apache7 来输入并行部署的字符##,如下所示:

<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<executions>
  <execution>
    <id>remote</id>
    <phase>deploy</phase>
    <goals>
      <goal>deploy</goal>
    </goals>
    <configuration>
      <mode>war</mode>
      <path>/${project.artifactId}-##${project.version}</path>
      <url>http://tomcat7.../manager/text</url>
      <username>user</username>
      <password>password</password>
      <update>true</update>
    </configuration>
  </execution>
</executions>
</plugin>
于 2013-09-22T05:50:11.067 回答