Maven

groupId 此元素指示创建项目的组织或组的唯一标识符。 groupId是项目的关键标识符之一,通常基于组织的完全限定域名。 例如,org.apache.maven.plugins 是所有Maven插件的指定groupId。

${basedir} represents the directory containing pom.xml

http://repo.maven.apache.org/maven2

Note that you can use the element to gain more control over the order of particular goals.

Project Inheritance - 项目继承

Introduce your own parent POMs by specifying the parent element in the POM

子模块会继承父项目的配置项

1
2
3
4
5
6
7
8
9
10
<project>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>my-module</artifactId>
</project>

备注:

  • 子模块未指定 groupIdvsersion, 将会从父 POM 中继承

  • 如果父项目没有安装在 repository 中或者父项目与子模块的目录层级不是下面这种:

1
2
3
4
.
|-- my-module
| `-- pom.xml # 子模块的POM
`-- pom.xml # 父POM

那么就需要通过 relativePath 标签指定父 POM 的路径,相对路径,相对于子模块的 POM 的路径

Project Aggregation - 项目聚合(集成)

Instead of specifying the parent POM from the module, it specifies the modules from the parent POM

父项目中知道自己有哪些子模块,在父项目中调用了 Maven 命令, 这些 Maven 命令也会在子模块中执行。

  • 在父 POM 中指定 packaging 的值为 “pom”
1
<packaging>pom</packaging>
  • 在父 POM 中指定子模块(子PMO)的目录 -相对路径,相对于父 POM 的路径
1
2
3
4
<modules>
<module>my-module</module>
<module>../my-module</module>
</modules>

Dependency mediation

这将确定在遇到多个版本作为依赖项时将选择哪个版本的工件。 Maven选择“最接近的定义”。 也就是说,它在依赖树中使用与项目最接近的依赖项版本。 您可以通过在项目的POM中明确声明它来保证版本。 请注意,如果两个依赖项版本在依赖关系树中处于相同深度,则第一个声明将获胜。

1
2
3
4
5
6
mvn archetype:generate \
-DgroupId=com.mycompany.app \
-DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DarchetypeVersion=1.4 \
-DinteractiveMode=false

URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)

assembly 3.1 和 2.5 的版本竟然会之执行不一样,

1
2
3
<scope>provided</scope>
<!--禁止传递依赖-->
<useTransitiveDependencies>true</useTransitiveDependencies>

3.1 版本, useTransitiveDependencies 设置为 true, scope 为 provided 的依赖不会拉进来?

MySQL 8.0.16 JDBC 数据库连接问题

MySQL 8.0.16 JDBC 数据库连接问题

Mysql 版本:mysql Ver 8.0.16 for Win64 on x86_64 (MySQL Community Server - GPL), 使用 5.x.x 或较低版本的 JDBC driver for MySQL 会出现连接问题:

1
2
3
Caused by: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
at com.mysql.jdbc.ConnectionImpl.buildCollationMapping(ConnectionImpl.java:1019)
... 16 more

需要修改驱动器为对应的版本

1
2
3
4
5
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>

InvalidConnectionAttributeException

1
2
3
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 

The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

url 设置 serverTimezone属性

1
jdbc:mysql://localhost:3306/world?serverTimezone=UTC

MySQL Connector/J Database URL

1
2
3
4
jdbc:mysql://[host][,failoverhost...]
[:port]/[database]
[?propertyName1][=propertyValue1]
[&propertyName2][=propertyValue2]...

left join 与 left outer join 的区别

事务的隔离级别

Vector 的使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@CallerSensitive
public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<>();

Class<?> callerClass = Reflection.getCallerClass();

// Walk through the loaded registeredDrivers.
for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerClass)) {
result.addElement(aDriver.driver);
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
return (result.elements());
}

1 运行前的配置

1 运行前的配置

1.1 用户信息配置

Git 自带一个 git config 的工具来设置 Git 外观和行为的配置参数。有三个不同级别的设置,分别对应不同的文件夹和作用域。

  1. 如果使用带有--system 选项的 git config 时,他会从文件 /etc/gitconfig 文件中进行配置变量的读写。==包含对系统上每一个用户及他们仓库的通用配置==。
  1. 如果使用带有 --global 选现的 git config 时,他会从文件 ~/.gitconfig~/.config/git/config 文件中进行配置变量的读写。==只针对当前用户==。
  1. 当前使用仓库的 Git 目录中的 config 文件(.git/config): ==只针对该仓库==

每一个级别覆盖上一个级别的配置。所以 .git/config 的配置变量会覆盖 /etc/gitconfig 中的配置变量。

在 Windows 系统中,Git 会查找 $HOME 目录下(一般情况是 C:\Users\$USER)的 .gitconfig 文件。 Git 同样也会寻找 /etc/gitconfig 文件,但只限于 MSys 的根目录下,即安装 Git 时所选的目标位置。

1
2
3
4
5
# 为当前用户配置用户名
git config --global user.name Guo

# 为当前用户配置邮箱
git config --global user.email email@company.com

1.2 文本编辑器

既然用户信息已经设置完毕,你可以配置默认文本编辑器了,当 Git 需要你输入信息时会调用它。 如果未配置,Git 会使用操作系统默认的文本编辑器,通常是 Vim。 如果你想使用不同的文本编辑器,例如 Emacs,可以这样做:

1
git config --global core.editor emacs

1.3 检查配置信息

1
2
git config --list
git config --global user.name

3 分支

分支

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 创建分支
git branch branchname

# 切换分支
git checkout branchname

# -----------------------------------------

# 创建并切换分支
git checkout -b branchname



# 删除分支
git branch -d branchname


# 显示所有的分支及当前所在分支
git branch

# 进一步显示所有分支的最后一次提交
git branch -v

–merged 与 –no-merged 这两个有用的选项可以过滤这个列表中已经合并或尚未合并到当前分支的分支。 如果要查看哪些分支已经合并到当前分支,可以运行 git branch –merged:

1
2
3
git branch --merged
iss53
* master

查看所有包含未合并工作的分支,可以运行 git branch --no-merged

1
2
$ git branch --no-merged
testing

这里显示了其他分支。 因为它包含了还未合并的工作,尝试使用 git branch -d 命令删除它时会失败:

1
2
3
git branch -d testing
error: The branch 'testing' is not fully merged.
If you are sure you want to delete it, run 'git branch -D testing'.

如果真的想要删除分支并丢掉那些工作,如同帮助信息里所指出的,可以使用 -D 选项强制删除它。

变基操作

在本地仓库的 master 分之下执行变基操作时,默认以本地 refs/origin/master (前提是通过 git fetch 进行抓取过了) 为变基操作的目标基地分支。

1
2
3
4
git rebase

# 修改冲突后
git rebase --continue

本地 master 的分支与 res/origin/master 的分支有共同的祖先,找出本地 master 分支相对于 res/origin/master的修改,并将其应用到 res/origin/master 的分支上,(这时,可能需要修改冲突的地方后继续), res/origin/master 分支和本地master分支共同指向最新的合并后的分支,git push 将本地 master 的分支推送到远程仓库的 master 分支,完成了 res/origin/master 分支和本地master分支的变基操作。

合并操作

在本地仓库的 master 分之下执行合并操作时,默认以 refs/origin/master 为要合并的另一个分支。

1
2
3
4
git merge

# 修改冲突后
git commit -a -m "decscription"

进行一次三方合并后,本地master分支的最新提交对象推送到远程仓库完成了合并操作。

README

Pro-Git-Note

Markdown notes for Pro Git
Love the life you live.
Live the life you love.
Find your own thing.