• maven


    maven的定义:项目生命周期的管理,基于plugin的开源工具。

    1. maven的生命周期
      1. 各个周期的定义:如compile、test、deploy等
      2. 每个生命周期指定一个或多个plugin
    2. POM
      1. 项目基本信息
        1. groupId、artifactid、version、packaging
          1. 项目基本信息
        2. dependencies、dependencyManagement
          1. dependencyManagement管理项目的依赖指定,特别是多个子项目的共同依赖的管理
          2. dependencies:具体依赖的管理
        3. parent
          1. 父pom的依赖说明
        4. modules
          1. 多模块工程中用于各个子模块的说明。
        5. properties
          1. name-value值对的特殊说明,常用于多处地方同时使用时,在一个地方指定,便于修改和查看。
      2. 构建settings设置
        1. build标签
          1. 构建时属性的指定
          2. 可以指定:
            1. goal:构建生命周期
            2. resources:路径指定或包含的文件指定,需要特殊说明时使用
            3. test-resources:测试类文件或路径指定,需要特殊说明时使用
            4. filters:过滤器,用于特殊的配置文件等的说明。
            5. plugins:插件配置。用于指定该build使用的plugin,否则使用默认。各个插件配置时除了指定groupid、artifactid、version外,还需要指定特殊的参数,可以见maven官网的插件列表,进行使用。packaging等的说明。
              1. 对execution的特殊说明:
              2. <executions> <!-- 配置插件在哪个阶段使用 -->
                        <execution>
                          <id>echodir</id>
                          <goals>
                            <goal>run</goal>
                          </goals>
                          <phase>verify</phase>
                          <inherited>false</inherited>
                          <configuration>
                            <tasks>
                              <echo>Build Dir: ${project.build.directory}</echo>
                            </tasks>
                          </configuration>
                        </execution>
                      </executions>
                
            6. extension:扩展插件。
        2. reporting标签
          1. 生成报告配置项,用于site阶段生成各个报表的配置
            • <reporting>
                  <plugins>
                    <plugin>
                      <outputDirectory>${basedir}/target/site</outputDirectory>
                      <artifactId>maven-project-info-reports-plugin</artifactId>
                      <reportSets>
                        <reportSet></reportSet>
                      </reportSets>
                    </plugin>
                  </plugins>
                </reporting>

              多个report使用reportSets:

            • <reporting>
                  <plugins>
                    <plugin>
                      ...
                      <reportSets>
                        <reportSet>
                          <id>sunlink</id>
                          <reports>
                            <report>javadoc</report>
                          </reports>
                          <inherited>true</inherited>
                          <configuration>
                            <links>
                              <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
                            </links>
                          </configuration>
                        </reportSet>
                      </reportSets>
                    </plugin>
                  </plugins>
                </reporting>
              
      3. project meta data
        1. name
        2. description
        3. url
        4. inceptionYear
        5. licenses
        6. organization
        7. developers
        8. contributions
      4. 环境设置
        1. issueManagement
        2. ciManagement
        3. mailingList
        4. scm
        5. prerequisites
        6. repositories
        7. pluginRepositories
        8. distributionManagement:发布设置
          • <distributionManagement>
            <repository>
            <id>proficio-repository</id>
            <name>Proficio Repository</name>
            <url>file://${basedir}/target/deploy</url>
            </repository>
            </distributionManagement>
        9. profiles:类似于settings.xml中的profiles,增加了几个元素,如下的样式:
            <profiles>
              <profile>
                <id>test</id>
                <activation>...</activation>
                <build>...</build>
                <modules>...</modules>
                <repositories>...</repositories>
                <pluginRepositories>...</pluginRepositories>
                <dependencies>...</dependencies>
                <reporting>...</reporting>
                <dependencyManagement>...</dependencyManagement>
                <distributionManagement>...</distributionManagement>
              </profile>
            </profiles>
          

            

    3. settings.xml
      1. 示例:
        • <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                                http://maven.apache.org/xsd/settings-1.0.0.xsd">
            <localRepository/> <!-- 指定本地仓库位置 -->
            <interactiveMode/> <!-- 指定 maven 的运行模式是否为交互模式 -->
            <usePluginRegistry/> <!-- 目前少用,指定插件配置文件 -->
            <offline/> <!-- 指定是否为离线模式,在不需要网络交互的时候使用 -->
            <pluginGroups/> <!-- 指定插件所在的路径,maven 将通过该路径查找插件 -->
            <servers/> <!-- 指定服务器的用户名、密码等,用于上传,下载文件等 -->
            <mirrors/> <!-- 指定 maven 主仓库的镜像 -->
            <proxies/> <!-- 网络代理配置,用于有代理的网络 -->
            <profiles/> <!-- pom.xml 中的 profile 能够用于公共配置的部分 -->
            <activeProfiles/>
          </settings>

          示例:
          <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
            ...
            <servers>
              <server> <!-- 设置发布 jar 包时的用户名及密码 -->
                <id>deploymentRepo</id>
                <username>deployment</username>
                <password>deployment123</password>
              </server>
            </servers>
            ...
            <mirrors>
              <mirror> <!-- 设置 maven 的远程仓库为 nexus -->
                <id>nexus</id>
                <mirrorOf>*</mirrorOf>
                <name>Local Repository</name>
                <url>http://192.168.1.60:8081/nexus/content/groups/public</url>
              </mirror>
            </mirrors>
            ...
            <profiles>
              ...
              <profile> <!-- 设置 nexus 的路径等 -->
                <id>nexus</id>
                <repositories>
                  <repository>
                    <id>central</id>
                    <name>local private nexus</name>
                    <url>http://localhost:8081/nexus/content/groups/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                  </repository>
                </repositories>
                <pluginRepositories>
                  <pluginRepository>
                    <id>central</id>
                    <name>local private nexus</name>
                    <url>http://localhost:8081/nexus/content/groups/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                  </pluginRepository>
                </pluginRepositories>
              </profile>
              ...
            </profiles>
            ...
            <activeProfiles> <!-- 激活 nexus -->
              <activeProfile>nexus</activeProfile>
            </activeProfiles>
            ...
          </settings>  
  • 相关阅读:
    nginx把POST转GET请求解决405问题
    Redis安装与配置
    SQL语句-SELECT语句
    SQL语句-delete语句
    SQL语句-UPDATE语句
    SQL语句-INSERT语句
    SQL语句-create语句
    MySQL权限详解
    GTID复制详解
    ansible-playbook的应用实例
  • 原文地址:https://www.cnblogs.com/leeying/p/3525775.html
Copyright © 2020-2023  润新知