【发布时间】:2010-10-08 18:16:45
【问题描述】:
我有一个Maven 项目,有 4 个组件 Web、Persistence、Common 和 Other。
我的POM 文件中的相关内容:
父 POM:
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>components/TestWeb</module>
<module>components/TestOther</module>
<module>components/TestPersistence</module>
<module>components/TestCommon</module>
</modules>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<dependentWarExcludes>
**/hibernate.cfg.xml,**/sql-map-config.xml,**/web.xml,WEB-INF/classes/META-INF/**
</dependentWarExcludes>
</configuration>
</plugin>
</plugins>
</build>
常见的pom:
<modelVersion>4.0.0</modelVersion>
<artifactId>test-common</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>0.0.1-SNAPSHOT</version>
</parent>
持久化pom:
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test-persistence</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>test-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
网络 pom:
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test-web</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>TestWeb</name>
<parent>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<relativePath>../../pom.xml</relativePath>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependency>
<groupId>com.test</groupId>
<artifactId>test-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.test</groupId>
<artifactId>test-persistence</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.test</groupId>
<artifactId>test-other</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
也许我在复制和粘贴中破坏了某些东西,但 XML 是有效的。
- 当我运行 mvn package 时,没有创建项目 WAR file,但所有组件包都已创建且格式正确。
- 然后,如果我运行
mvn war:war,则生成的 WAR 文件为空。
如何解决这个问题?
【问题讨论】:
标签: java maven-2 maven-war-plugin