首页 > 代码库 > Maven 项目多运行环境配置(原创)

Maven 项目多运行环境配置(原创)

<?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>    <parent>        <artifactId>cmdra-project</artifactId>        <groupId>com.hz.cmdra</groupId>        <version>1.0-SNAPSHOT</version>    </parent>    <artifactId>cmdra-project-web</artifactId>    <packaging>war</packaging>    <name>${project.artifactId}</name>    <url>http://maven.apache.org</url>    <dependencies>        <dependency>            <groupId>com.hz.cmdra</groupId>            <artifactId>cmdra-project-service-atom</artifactId>        </dependency>    </dependencies>    <profiles>        <!-- 本地 -->        <profile>            <id>local</id>            <activation>                <activeByDefault>true</activeByDefault>            </activation>            <properties>                <env>local</env>            </properties>        </profile>        <!-- 开发 -->        <profile>            <id>dev</id>            <properties>                <env>dev</env>            </properties>        </profile>        <!-- 预发布 -->        <profile>            <id>pre</id>            <properties>                <env>pre</env>            </properties>        </profile>        <!-- 生产 -->        <profile>            <id>prod</id>            <properties>                <env>prod</env>            </properties>        </profile>    </profiles>    <build>        <finalName>cmdra</finalName>        <resources>            <resource>                <directory>src/main/resources</directory>            </resource>            <resource>                <directory>src/main/resources_${env}</directory>                <filtering>true</filtering>            </resource>        </resources>        <plugins>            <!-- jetty -->            <plugin>                <groupId>org.eclipse.jetty</groupId>                <artifactId>jetty-maven-plugin</artifactId>                <version>9.3.2.v20150730</version>                <configuration>                    <httpConnector>                        <port>8888</port>                    </httpConnector>                </configuration>            </plugin>            <plugin>                <artifactId>maven-war-plugin</artifactId>                <version>2.6</version>                <executions>                    <execution>                        <phase>package</phase>                        <goals>                            <goal>                                war                            </goal>                        </goals>                        <configuration>                            <classifier>                                ${env}                            </classifier>                        </configuration>                    </execution>                </executions>            </plugin>        </plugins>    </build></project>

 

Maven 项目多运行环境配置(原创)