maven pom.xml(二)

来源:互联网 发布:studio lee 类似 淘宝 编辑:程序博客网 时间:2024/05/16 04:41
<?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>指定,子项目继承父项目的大部分属性  //父项目的打包方式为pom 一般父项目定义jar包的版本,使子项目版本统一  <parent>    <groupId>yeyi0909</groupId>    <artifactId>fast-cms</artifactId>    <version>0.0.1-SNAPSHOT</version>  </parent>  <artifactId>fast-cms-core</artifactId>  //打包方式      <packaging>war</packaging>  <name>fast-cms-core</name>  <url>http://maven.apache.org</url>  <properties>     <thymeleaf.version>3.0.6.RELEASE</thymeleaf.version>    <thymeleaf-spring.version>3.0.6.RELEASE</thymeleaf-spring.version>    <layout-dialect>2.1.2</layout-dialect>  </properties>  <dependencies>    <dependency>        <groupId>yeyi0909</groupId>        <artifactId>fast-cms-common</artifactId>        <version>0.0.1-SNAPSHOT</version>    </dependency>    <!-- Thymeleaf begin-->    <dependency>        <groupId>org.thymeleaf</groupId>        <artifactId>thymeleaf</artifactId>        <version>${thymeleaf.version}</version>    </dependency>    <dependency>        <groupId>org.thymeleaf</groupId>        <artifactId>thymeleaf-spring4</artifactId>        <version>${thymeleaf-spring.version}</version>    </dependency>    <!-- Thymeleaf end-->    <!-- Layout dialect begin-->    <dependency>        <groupId>nz.net.ultraq.thymeleaf</groupId>        <artifactId>thymeleaf-layout-dialect</artifactId>        <version>${layout-dialect}</version>    </dependency>    <!-- Layout dialect end-->  </dependencies>  <profiles>     <-- maven-war-plugin将根据不同打包参数设置-->     <--可以根据不同环境的配置文件-->     <--开发环境:maven packageP dev profiles.active的值为dev-->       <--生产环境:maven packageP online profiles.active的值为online ->         <profile>            <!-- 生产环境 -->            <id>online</id>            //默认profiles.active的值为online            <properties>                <profiles.active>online</profiles.active>            </properties>            <activation>                <activeByDefault>true</activeByDefault>            </activation>        </profile>        <profile>            <!-- 本地开发环境 (测试环境)-->            <id>dev</id>            <properties>                <profiles.active>dev</profiles.active>            </properties>        </profile>  </profiles>  <build>        <!-- 这个是打包的时候生成的名字 -->        <finalName>fast-cms</finalName>        <resources>        //过滤文件            <!-- class文件打包成war包,排除相关配置文件,            -->            <resource>                <directory>src/main/resources</directory>                <excludes>                    <exclude>dev/*</exclude>                    <exclude>online/*</exclude>                </excludes>                <filtering>true</filtering>            </resource>        </resources>        <!-- 插件配置 -->        <plugins>            <plugin>                <artifactId>maven-compiler-plugin</artifactId>                <configuration>                    <source>1.8</source>                    <target>1.8</target>                    <encoding>UTF-8</encoding>                    <showWarnings>true</showWarnings>                </configuration>            </plugin>            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-war-plugin</artifactId>                <configuration>                    <failOnMissingWebXml>false</failOnMissingWebXml>                    <!-- 使用打包参数对应的配置文件设置项目对应的配置文件 -->                    <webResources>                        <resource>             <!-- 根据不同环境profiles.active的值,编译不同的配置文件 -->                                <directory>src/main/resources/${profiles.active}</directory>                            <filtering>true</filtering>                            <targetPath>WEB-INF/classes</targetPath>                        </resource>                    </webResources>                </configuration>            </plugin>        </plugins>        <defaultGoal>compile</defaultGoal>    </build></project>
原创粉丝点击