
如果您有一个多模块项目,则需要类似以下的结构,该结构也将由文件夹结构表示。
+-- root (pom.xml) +--- module-1 +--- module-2 +--- module-war
而根模块包含如下内容:
<project ..> <groupId>com.test.project</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> <modules> <module>module-1</module> <module>module-2</module> <module>module-war</module> </modules></project>
在模块1中,您的pom应该如下所示:
<project ..> <parent> <groupId>com.test.project</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>module-1</artifactId> dependencies for the module</project>
在第2单元中,它看起来大致相同。在战争模块中,它看起来像:
<project ..> <parent> <groupId>com.test.project</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <packaging>war</packaging> <artifactId>module-war</artifactId> dependencies for the module</project>
如果您在模块之间具有依赖关系,例如,模块1依赖于模块2,则在模块1中如下所示:
<project ..> <parent> <groupId>com.test.project</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>module-1</artifactId> <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>module-2</artifactId> <version>{project.version}</version> </dependency> ..other dependencies.. </dependencies></project>要构建和打包您的项目,您将转到父文件夹,然后简单地执行
mvn clean package
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)