Maven| Maven相关概念

Maven仓库加载

Maven 远程仓库默认配置文件:
$MAVEN_HOME/lib/maven-model-builder-3.3.3.jar
文件:org\apache\maven\model\pom-4.0.0.xml
例如:
博主的是在D:\ProgramFiles\apache-maven-3.5.0\lib\maven-model-builder-3.5.0.jar
文件:org\apache\maven\model\pom-4.0.0.xml






<project>
    <modelVersion>4.0.0modelVersion>

    <repositories>
        <repository>
            <id>centralid>
            <name>Central Repositoryname>
            <url>https://repo.maven.apache.org/maven2url>
            <layout>defaultlayout>
            <snapshots>
                <enabled>falseenabled>
            snapshots>
        repository>
    repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>centralid>
            <name>Central Repositoryname>
            <url>https://repo.maven.apache.org/maven2url>
            <layout>defaultlayout>
            <snapshots>
                <enabled>falseenabled>
            snapshots>
            <releases>
                <updatePolicy>neverupdatePolicy>
            releases>
        pluginRepository>
    pluginRepositories>

    <build>
        <directory>${project.basedir}/targetdirectory>
        <outputDirectory>${project.build.directory}/classesoutputDirectory>
        <finalName>${project.artifactId}-${project.version}finalName>
        <testOutputDirectory>${project.build.directory}/test-classestestOutputDirectory>
        <sourceDirectory>${project.basedir}/src/main/javasourceDirectory>
        <scriptSourceDirectory>${project.basedir}/src/main/scriptsscriptSourceDirectory>
        <testSourceDirectory>${project.basedir}/src/test/javatestSourceDirectory>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resourcesdirectory>
            resource>
        resources>
        <testResources>
            <testResource>
                <directory>${project.basedir}/src/test/resourcesdirectory>
            testResource>
        testResources>
        <pluginManagement>
            
            
            <plugins>
                <plugin>
                    <artifactId>maven-antrun-pluginartifactId>
                    <version>1.3version>
                plugin>
                <plugin>
                    <artifactId>maven-assembly-pluginartifactId>
                    <version>2.2-beta-5version>
                plugin>
                <plugin>
                    <artifactId>maven-dependency-pluginartifactId>
                    <version>2.8version>
                plugin>
                <plugin>
                    <artifactId>maven-release-pluginartifactId>
                    <version>2.3.2version>
                plugin>
            plugins>
        pluginManagement>
    build>

    <reporting>
        <outputDirectory>${project.build.directory}/siteoutputDirectory>
    reporting>

    <profiles>
        
        <profile>
            <id>release-profileid>

            <activation>
                <property>
                    <name>performReleasename>
                    <value>truevalue>
                property>
            activation>

            <build>
                <plugins>
                    <plugin>
                        <inherited>trueinherited>
                        <artifactId>maven-source-pluginartifactId>
                        <executions>
                            <execution>
                                <id>attach-sourcesid>
                                <goals>
                                    <goal>jargoal>
                                goals>
                            execution>
                        executions>
                    plugin>
                    <plugin>
                        <inherited>trueinherited>
                        <artifactId>maven-javadoc-pluginartifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocsid>
                                <goals>
                                    <goal>jargoal>
                                goals>
                            execution>
                        executions>
                    plugin>
                    <plugin>
                        <inherited>trueinherited>
                        <artifactId>maven-deploy-pluginartifactId>
                        <configuration>
                            <updateReleaseInfo>trueupdateReleaseInfo>
                        configuration>
                    plugin>
                plugins>
            build>
        profile>
    profiles>

project>

Maven 依赖特性

依赖选择:(最短路径原则和最先申明原则)
(一)选p2 ,(二)选p3

(一)
A-> B -> C ->D ->X ( P1 )
A -> D -> X ( P2 )
(二)
A -> B ->X ( P3 )
A -> C ->X ( P4 )
依赖传递依赖特性:
Maven| Maven相关概念_第1张图片


Maven 聚合与继承特性

在父的管理模块统一聚合管理子项目

    
    <modules>
        <module>../yves-daomodule>
        <module>../yves-servicemodule>
        <module>../yves-webmodule>
    modules>

    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.mybatisgroupId>
                <artifactId>mybatisartifactId>
                <version>3.3.0version>
            dependency>
            ...

        dependencies>
    dependencyManagement>

子项目中可以继承父项目里面的依赖

    
    <parent>
        <groupId>cn.com.yvesgroupId>
        <artifactId>yves-parentartifactId>
        <version>0.0.1-SNAPSHOTversion>
        <relativePath>../yves-parent/pom.xmlrelativePath>  
    parent>

maven依赖的聚合依赖例子:
聚合和继承的例子

你可能感兴趣的:(【Maven】)