您将需要3 pom,这是一个工作示例;
pom 1是父母
<?xml version="1.0" encoding="UTF-8"?><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.greg</groupId> <artifactId>ear-example</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <name>ear-example</name> <modules> <module>example-jar</module> <module>example-ear</module> </modules></project>
pom 2是罐子或战争
<?xml version="1.0"?><project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.greg</groupId> <artifactId>ear-example</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>example-jar</artifactId> <packaging>jar</packaging> <name>com.greg</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies></project>
pom 3是依赖于jar / war的耳朵
<?xml version="1.0"?><project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.greg</groupId> <artifactId>ear-example</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>example-ear</artifactId> <packaging>ear</packaging> <dependencies> <dependency> <groupId>com.greg</groupId> <artifactId>example-jar</artifactId> <version>${project.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-ear-plugin</artifactId> <version>2.10.1</version> <configuration> </configuration> </plugin> </plugins> </build></project>


