运行父maven项目时获取war模块

时间:2015-03-23 15:29:59

标签: maven

有没有办法在运行父项目时自动运行war模块? 为了说清楚,我做了三个独立的maven项目(db,core和presentation),然后我创建了一个包含前面提到的3个项目的父项目。 我想在运行父项目时运行演示模块。

另外,我想知道是否可以将漏洞工作从父项目保存到我的git帐户。

     <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.project.xxxxxxx</groupId>
  <artifactId>parent-project</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <name>parent-project</name>
  <url>http://maven.apache.org</url>

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

  <build>

        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <port>8080</port>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${targetJdk}</source>
                    <target>${targetJdk}</target>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <modules>
        <module>../project-db</module>
        <module>../project-core</module>
        <module>../project-presentation</module>
    </modules>


  <dependencies>

  </dependencies>
</project>

2 个答案:

答案 0 :(得分:0)

您需要在标记下指定子项目。 您可以参考http://books.sonatype.com/mvnex-book/reference/multimodule-sect-simple-parent.html例如

答案 1 :(得分:0)

您的模块应该在文件结构中取代您的父级。像

  • 父项目
    • 的pom.xml
    • 项目分贝
      • 的pom.xml
    • 项目核心
      • 的pom.xml
    • 项目呈递
      • 的pom.xml

然后你必须改变父pom:

<modules>
    <module>project-db</module>
    <module>project-core</module>
    <module>project-presentation</module>
</modules>