maven parent pom

parent pom:全局定义项目模型,子pom继承父pom的配置

主要配置:
           定义项目基本信息:比如license
<licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url> http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

 定义公司统一仓库位置:比如jardeploy位置
    <!-- 发布位置配置 -->
    <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <name>Internal Release Repository</name>
            <url> http://nexus.xxx.com/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>Internal Snapshot Repository</name>
            <url> http://nexus.xxx.com/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>


定义全局插件:比如built方式
<plugins>
            <plugin>
                <inherited>true</inherited>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <optimize>true</optimize>
                    <debug>true</debug>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <!-- 发布源代码jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>deploy</phase>
                    </execution>
                </executions>
            </plugin>

            <!-- 发布javadoc -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.8.1</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

统一管理jar版本:子项目在引入jar时不需要加入version 和scope属性:例如
<!--管理jar包版本-->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.peaceful</groupId>
                <artifactId>nuggets-peaceful-utils</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

          
定义公司统一jar包依赖:这样所有通过配置parent的项目都可以把下面jar依赖到自己项目里,例如
             <dependencies>
       <!--  JUNIT DEPENDENCY FOR TESTING -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

总结parent pom主要是用来全局描述项目模型
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值