我可以使用maven战争来覆盖已经存在的其他项目吗?

时间:2015-12-16 09:45:07

标签: java spring maven jsp war

我是Spring和Maven的初学者。

在Spring Framework中, 我想管理一个单独的版本控制流程。

1. Main Project that already exist.
2. Module of the partial use that packaged by maven war.

推拉时,应分别处理两个项目。

但两个项目上的文件可能存在于同一个文件夹中。

我该如何使用?

2 个答案:

答案 0 :(得分:1)

这实际上与您当前使用的版本控制系统有关。 Git例如支持子模块。您可以直接在根项目文件夹中创建maven模块,并将其定义为git子模块。所以他们有不同的git轨道,可以单独维护。

答案 1 :(得分:1)

我相信你所需要的东西可以通过使用'war-overlays'来实现,如记录here

总而言之,您将'child'项目指定为'Main'项目中的依赖项:

...
  <dependencies>
    <dependency>
      <groupId>com.example.projects</groupId>
      <artifactId>documentedprojectdependency</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>war</type>
      <scope>runtime</scope>
    </dependency>
    ...
  </dependencies>
  ...

您可以在maven-war-plugin的配置中定义叠加层:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <overlays>
                <overlay>
                    <id>my-webapp-index.jsp</id>
                    <groupId>com.example.projects</groupId>
                    <artifactId>my-webapp</artifactId>
                    <includes>
                        <include>index.jsp</include>
                    </includes>
                </overlay>
                <overlay>
                    <!-- empty groupId/artifactId represents the current build -->
                </overlay>
            </overlays>
        </configuration>
    </plugin>