0%

POM 关系

Maven 一个很强的地方是它的对于项目关系的处理,包含了依赖(transitive dependencies,在这里可能应该理解为传递依赖),继承,和聚合(多模块项目)。

Dependencies 依赖

1
2
3
4
5
6
7
8
9
10
11
12
13
...
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<type>jar</type>
<scope>test</scope>
<optional>true</optional>
</dependency>
...
</dependencies>
...

groupId、artifactId、version:
这里的 version 还可以用一种专门的语法来约束,不需要指定固定的某一个版本,这个知识点在别的笔记里面记录过,这个知识点 JS、Python 也都是使用。

classifier:

The classifier distinguishes artifacts that were built from the same POM but differ in content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.
As a motivation for this element, consider for example a project that offers an artifact targeting Java 11 but at the same time also an artifact that still supports Java 1.8. The first artifact could be equipped with the classifier jdk11 and the second one with jdk8 such that clients can choose which one to use.
Another common use case for classifiers is to attach secondary artifacts to the project’s main artifact. If you browse the Maven central repository, you will notice that the classifiers sources and javadoc are used to deploy the project source code and API docs along with the packaged class files.

这个好像是说制品根据这个属性可以有不同的分类,例如可以生成支持 Java 11 的或者生成 Java 1.8 的,或者还可以生成附属的制品,例如 sources 和 javadoc。
其实总体来说,还是有些不明白。

type:
依赖的类型,默认是 jar。

scope:
范围,这个元素指的是手头任务的 classpath,以及如何限制依赖的传递性。
这个在 gradle 里面有对应的动词,可以对应总结一下。
在这里插入图片描述
in hand vs at hand vs on hand 的区别:
在这里插入图片描述

systemPath:

optional:

参考

https://maven.apache.org/pom.html#pom-relationships

Maven Coordinates 坐标

groupId、artifactId、version 是所有需要的字段,groupId 和 version 可以从一个 parent 文件中继承,这个时候它们可以不被明确定义。这三个字段扮演的就像地址和时间戳,它们在 Maven 项目中就像坐标系统一样,在一个仓库里面指定了一个特定的位置。

groupId:这个其实是组织的信息,组织的唯一标识,例如 org.apache.maven,不过这里不一定要一定使用点这个符号,也不必要一定要和项目的包结构对应上,当然,最好是对应上,这样其实在 maven 仓库里面就可以呈现出很好的目录结构。

groupId: This is generally unique amongst an organization or a project. For example, all core Maven artifacts do (well, should) live under the groupId org.apache.maven. Group ID’s do not necessarily use the dot notation, for example, the junit project. Note that the dot-notated groupId does not have to correspond to the package structure that the project contains. It is, however, a good practice to follow. When stored within a repository, the group acts much like the Java packaging structure does in an operating system. The dots are replaced by OS specific directory separators (such as ‘/‘ in Unix) which becomes a relative directory structure from the base repository. In the example given, the org.codehaus.mojo group lives within the directory $M2_REPO/org/codehaus/mojo.

artifactId:制品 Id,这个是在 group 下面一级的概念,是在组织内部用来区分的信息,理解上感觉就是组织下面的项目。

version: 版本信息,在制品信息内部来区分各个版本的信息。

This is the last piece of the naming puzzle. groupId:artifactId denotes a single project but they cannot delineate which incarnation of that project we are talking about.

参考

https://maven.apache.org/pom.html#Maven_Coordinates

概要

CAS Compare and Swap 学习,看到网上到处有人说 CAS 是一种无锁算法,实在是有点忍不住,这种对于技术的研究,需要一种寻根究底的态度,模棱两可没掌握清楚,就随便发帖,然后后面的人也是人云亦云,这样整体的技术水平怎么可能得到提高呢?

阅读全文 »

前言

英语中总会出现i.e.这个字样,以前查过一次,好像就是举例子的意思,最近又忘记了,记一下笔记,深化一下。

阅读全文 »

前言

14年创业时,学习过 ES,15年到了厦门,又复习了一遍,现在用到了,所以叫再识。

暂时缺乏一个很好的思路去记录这个笔记,那么还是按照最老实的方式来记录,就是对官网的文章一篇一篇地去学习,记录笔记。

阅读全文 »

学 Python 也有一段时间了,一直没有搞清楚 module 和 package 的区别和概念,走了一些弯路,所以需要做做笔记,总结一下。

本文结合着对于这篇文章的阅读,进行记录笔记,不打算全文翻译,那样没有意义,扼要地记录关键的,感觉需要记录的内容。

阅读全文 »