Maven 学习

1、构建项目中的细节

     groupId :the unique identifier of the organization or group that created the project (创建该项目的组织或者小组的唯一标识)

        例子:比如我的组织叫做ant,项目名称jeepe ,那么可以将groupid定义为  com.ant.jeepe

    artifactId :unique base name of the primary artifact being generated by this project(该项目中的主要子项的唯一基本名称标识)

              例子:项目名称jeepe ,项目下的api子模块,可以定义为  jeepe-api

   name:     声明了一个对于用户更为友好的项目名称,不是必须的,推荐为每个pom声明name,以方便信息交流,,可以和artifactId 保持一致

 

2、继承和聚合

    2.1、继承是为了解决依赖复用的问题,消除重复配置,比如三个子模块都用到了一个依赖,那么就可以抽离到parent依赖中统一管理。

      

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?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>
 
 
  <groupId>com.ant.parent</groupId>
  <artifactId>ant-parent</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>ant-parent</name>
 
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <spring-boot.version>2.1.6.RELEASE</spring-boot.version>
    <dubbo.version>2.7.3</dubbo.version>
    <dubbo-spring-boot.version>2.7.3</dubbo-spring-boot.version>
    <curator.famework.version>4.2.0</curator.famework.version>
  </properties>
 
  <distributionManagement>
    <repository>
      <id>maven-release</id>
      <name>Nexus Release Repository</name>
      <url>http://maven.igper.com/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
      <id>maven-snapshots</id>
      <name>Nexus Snapshot Repository</name>
      <url>http://maven.igper.com/repository/maven-snapshots/</url>
    </snapshotRepository>
  </distributionManagement>
 
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
       
      <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>${javax.mail.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${spring-boot.version}</version>
        </plugin>
        <plugin>
          <groupId>org.mybatis.generator</groupId>
          <artifactId>mybatis-generator-maven-plugin</artifactId>
          <version>1.3.7</version>
          <dependencies>
            <dependency>
              <groupId>mysql</groupId>
              <artifactId>mysql-connector-java</artifactId>
              <version>8.0.16</version>
            </dependency>
            <dependency>
              <groupId>org.mybatis.generator</groupId>
              <artifactId>mybatis-generator-core</artifactId>
              <version>1.3.7</version>
            </dependency>
            <dependency>
              <groupId>tk.mybatis</groupId>
              <artifactId>mapper</artifactId>
              <version>${tkmybatis.version}</version>
            </dependency>
 
          </dependencies>
          <executions>
            <execution>
              <id>Generate MyBatis Artifacts</id>
              <phase>package</phase>
              <goals>
                <goal>generate</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <!--允许移动生成的文件 -->
            <verbose>true</verbose>
            <!-- 是否覆盖 -->
            <overwrite>false</overwrite>
            <!-- 自动生成的配置 -->
            <configurationFile>src/main/resources/mybatis-generater.xml</configurationFile>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

  

    2.2、Maven 的聚合其实就是项目与子项目的表示,其存在的意义在于快速构建项目。

        

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?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>
 
    <groupId>com.gpmall.commons</groupId>
    <artifactId>gpmall-commons</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>commons-tool</module>
        <module>commons-core</module>
        <module>commons-lock</module>
        <module>commons-mq</module>
    </modules>
 
    <distributionManagement>
        <repository>
            <id>maven-release</id>
            <name>Nexus Release Repository</name>
            <url>http://maven.igper.com/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>maven-snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://maven.igper.com/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
 
    <name>gpmall-commons</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

  

posted on   滚动的蛋  阅读(234)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示