<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/maven-v4_0_0.xsd"> <!--父项目的相关信息--> <parent> <!--父项目的唯一标识符--> <artifactId>parentArtifactId</artifactId> <!--父项目的项目组织唯一标识符--> <groupId>parentGroupId</groupId> <!--父项目的项目版本--> <version>1.0-SNAPSHOT</version> </parent> <!--代表组织或整个项目的唯一标识符--> <groupId>demoGroupId</groupId> <!--是一个项目描述符,描述这个pom文件遵从哪个版本--> <modelVersion>4.0.0</modelVersion> <artifactId>demoArtifactId</artifactId> <packaging>war</packaging> <name>demo</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>com.demo.common</groupId> <artifactId>common-web</artifactId> <version>1.1.2</version> <!--去掉某个模块--> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.demo.common</groupId> <artifactId>common-struts</artifactId> <version>1.1.4-SNAPSHOT</version> <exclusions> <exclusion> <groupId>com.demo.common</groupId> <artifactId>common-web</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> <finalName>demo</finalName> <resources> <resource> <!--指定该目录下的文件可用${}的形式读取--> <directory>src/main/resources</directory> <!--过滤${}占位符,进而解析然后把pom文件中相应的属性(即profile中properties中的自定义标签)进行替换--> <filtering>true</filtering> </resource> </resources> </build> <!--根据此标签配置不同的配置环境,如数据源有开发、测试环境,就可在此配置--> <profiles> <profile> <!--该profile的标识,必须写--> <id>development</id> <!--该profile的配置,可以不写--> <properties> <!--自定义标签,写多少都行,都是你的配置,使用时用${}的形式获取,跟properties的读取方式一样--> <demo.jdbc.driver>com.mysql.jdbc.Driver</demo.jdbc.driver> </properties> </profile> <profile> <id>test</id> <properties> <demo.jdbc.driver>com.mysql.jdbc.Driver</demo.jdbc.driver> </properties> </profile> <profile> <id>production</id> <properties> <cm.jdbc.driver>com.mysql.jdbc.Driver</cm.jdbc.driver> </properties> </profile> </profiles></project>