WenLiangBaoBlog

个人博客


  • 首页

  • 标签7

  • 归档62

  • 搜索

4+1经典系统架构设计

发表于 2021-12-06 | 更新于 2021-12-08

经典系统设计架构(4+1)

经典系统架构4+1 是指4个业务视图+1个开发视图。其中4个业务视图分别为,场景视图、逻辑视图、物理视图、处理视图。

场景视图

负责从用户角度,识别业务需求,描述业务场景,是架构设计的起点和终点。

场景视图一般用于描述系统的参与者与功能用例间的关系,反映系统的最终需求和交互设计,通常由用例图表示。

用例图(英语:use case diagram)是用户与系统交互的最简表示形式,展现了用户和与他相关的用例之间的关系。通过用例图,人们可以获知系统不同种类的用户和用例。用例图也经常和其他图表配合使用。

一个简单的用例图如下图所示:

6f061d950a7b020838e8dfab68d9f2d3572cc853

逻辑视图

逻辑视图关注功能,不仅包括用户可见的功能,还包括为实现用户功能而必须提供的”辅助功能模块”,它们可能是逻辑层、功能模块等。通常使用UML组件图来绘制

逻辑视图

物理视图

物理视图关注”目标程序及其依赖的运行库和系统软件”最终如何安装或部署到物理机器,以及如何部署机器和网络来配合软件系统的可靠性、可伸缩性等要求。物理视图和处理视图的关系:处理视图特别关注目标程序的动态执行情况,而物理视图重视目标程序的静态位置问题;物理视图是综合考虑软件系统和整个IT系统相互影响的架构视图。

处理视图

处理视图关注进程、线程、对象等运行时概念,以及相关的并发、同步、通信等问题。处理视图和开发视图的关系:开发视图一般偏重程序包在编译时期的静态依赖关系,而这些程序运行起来之后会表现为对象、线程、进程,处理视图比较关注的正是这些运行时单元的交互问题。

处理流程视图

开发视图

开发视图关注程序包,不仅包括要编写的源程序,还包括可以直接使用的第三方SDK和现成框架、类库,以及开发的系统将运行于其上的系统软件或中间件。开发视图和逻辑视图之间可能存在一定的映射关系:比如逻辑层一般会映射到多个程序包等。

开发环境:

开发语言:Java、JavaScript、Html ;

数据库类型:MySQL 5.0 ;

应用服务器类型:Apache+JBOSS;

其他软件:Ant、JUnit 等

相关硬件:略

技术架构

SMM SpringMvc+spring+Mybatis

系统分层

经典3层设计思想 数据层、服务层、视图层

代码目录

代码目录

数字电子-计算机操作系统

发表于 2021-12-06

操作系统概论

操作系统的概念

计算机系统

knowledge point:

1.计算机系统是一种可以按用户要求接收和存储信息、自动进行数据处理并输出结果信息的系统。

2.广义的计算机系统包含机械式系统和电子式系统。

3.电子式系统可以分为模拟式和数字式计算机系统。本篇博客讨论的是数字电子计算机系统,也可简称为计算机系统。

操作系统的定义

knowledge point:

1.操作系统是计算机系统中的一个系统软件。或者说是一些程序模块的集合。

2.它能有效的管理计算机系统中的硬件和软件资源。也可以理解为,它是计算机暴露的接口,用户通过这些接口可以更好的利用计算机资源。

操作系统的特征

并发性

共享性

随机性

研究操作系统的观点

软件的观点

资源管理的观点

进程的观点

虚拟机的观点

服务提供者观点

操作系统的功能

进程管理

存储管理

文件管理

设备管理

用户接口

操作系统的体系结构

Windows操作系统的体系结构

Unix操作系统的体系结构

Linux操作系统的体系结构

Android操作系统的体系结构

操作系统的发展

手工操作

监控程序

多道批处理

分时与实时系统

Unix通用操作系统

个人计算机操作系统

Android操作系统

操作系统分类

批处理操作系统

分时系统

实时操作系统

嵌入式操作系统

个人计算机操作系统

网络操作系统

分布式操作系统

操作系统设计

操作系统的设计过程

操作系统的设计目标

操作系统的结构设计

操作系统的结构

Linux-软件管理篇

发表于 2021-12-06 | 更新于 2019-04-29

软件包管理简介

1554165969408

1554166782008

1554167202716

1554167710627

1554167773662

总结:Linux 软件安装包分为

​ 源码包安装

​ 优点:可控性高,可以自己查看或修改程序的源代码。安装后软件的执行效率高,比厂商提供的二进制包高5%

​ 缺点:需要自己手动编译源码后才可安装,操作难度高。

​ 二进制包安装

​ 优点:安装速度块,由于使用的是厂商编译过的二进制包,所有省去了自己对源码的手动编译。直接安装即可。

​ 缺点:不可以直接查看程序的源代码。安装后软件的执行效率比自己手动编译的的软件包慢5%。并且安装软件存在依赖性问题

​ 脚本包安装

​ 优点:脚本包安装类似与Windows下的软件安装界面。它是源码包安装和二进制包安装的中和方式。运行脚本后,脚本会帮助你去编译软件的源代码并安装。

​ 缺点:单独编写软件脚本

RPM 包管理(二进制包)

rpm的命名规则

1554169009132

包名或包全名例子

​ httpd-2.2.15-15.el6.centos.1.i686.rpm

​ 包名 : httpd

​ 包全名 : httpd-2.2.15-15.el6.centos.1.i686.rpm

rpm的依赖性

1554170327297

总结:

​ rpm包的命名规则:

​ 软件包名-软件版本-软件的发布次数.适合的Linux平台.适合的硬件平台.rpm包扩展名

​ rpm依赖性:

​ 树形依赖 :如安装软件包a时发现需要安装软件包b,而安装软件包b又需要软件包c.

解决上述的树形依赖问题的方法:先安装软件包c然后依次安装软件包b,软件包a

​ 环形依赖:如安装软件包a时发现需要安装软件包b,而安装软件包b需要安装软件包c,但是安装软件包c却需要软件包a,这样就形成了环形的依赖结构。

环形依赖解决方案:同时安装包a,b,c即可解决此问题。

​ 模块依赖:模块依赖和软件包依赖不同之处在于,模块所依赖的包,有可能不在系统安装包内。

解决方案:进入 www.rpmfind.net 搜索需要的模块包

包全名和包名的使用介绍

1554172185949

rpm安装升级卸载

1554172274777

1554172740075

1554172783240

总结:

  1. 什么时候使用包全名或包名

    1. 包全名,在软件没有安装并需要使用的情况下。如软件的安装或更新
    2. 包名,在软件已经被安装的情况下。如软件的卸载
  2. rpm实现包安装

    在进入安装包目录的情况下

    1
    rpm -ivh 需要安装的包全名(need install package name)
  3. rpm实现包升级

    在进入安装包目录的情况下

    1
    rpm -Uvh 需要更新的包全名(need update package name)
  4. rpm实现包卸载

    1
    rpm -e 需要卸载的包名 (need deleter package name)

rpm查询

查询是否安装

1554173640238

安装包的详细信息查询

1554174085399

RPM的安装位置查询

1554174169009

根据文件名查询rpm包

1554174656232

查询安装包的依赖性

1554174809684

总结:

rpm查询

  1. 查询是否安装

    1
    rpm -q 包名 (package name)

    系统已经安装的所有安装包

    1
    rpm -qa
  1. 安装包的详细信息查询

    1
    rpm -qi 包名 (package name)
  2. RPM的安装位置查询

    1
    rpm -ql 包名 (package name)
  1. 获取给定文件名属于哪个RPM

    1
    rpm -qf 文件名 (file name)
  1. 查询RPM的依赖性

    1
    rpm -qR 包名(package name)

rpm包校验

1554175762509

1554175960568

1554176086475

rpm包提取

1554176212571

1554176347181

总结:

rpm 包校验

rpm 包提取

/usr/bin/ls 文件提取

1
rpm2cpio /mnt/cdrom/Packages/coreutils-8.22-23.el7.x86_64.rpm | cpio -idv ./usr/bin/ls

yum在线管理-IP地址配置

使用 red heat 的setup命令

本人使用的是contos7,发现使用setup后没有网络配置项,在网上查他们说需要使用yum去安装setup的一些功能项。(未做测试)

那我是怎么配置使自己的系统可以访问外网的呢?我直接修改改network 的配置文件(/etc/sysconfig/network-scripts/ifcfg-ens33)文件,将ONBOOT 设为 true,然后就可以上网了。

网络yum源

本人安装的contos已经默认安装并配置了yum源,下面是有关yum源的一些配置属性的解释

1554189939317

使用镜像(mirror)

  1. 下载镜像repo配置文件 http://mirrors.aliyun.com/repo/Centos-7.repo
  2. 将原repo文件备份为 repo.backup
  3. 将下载好的Centos-7.repo 移动到/etc/yum.repos.d/下并改名为CentOS-Base.repo

总结:

​ 1.系统上网配置,使用setup 下的网络配置,配置ip 子网掩码 网关 CSDN 保存即可,设置后记得修改network 的网络配置文件,将ONBOOT 设为true, 之后service network restart 重启即可,然后使用ping命令测试系统是否联网

​ 2.yum 配置使用contos默认即可

​ 3.yum mirror设置,上述配置即可

yum命令

查询

1554192514578

安装

1554194593714

​ 注意 当更新时,没有指定包名,yum会更新整个系统中所有软件甚至内核也会被升级。

卸载

1554194899289

yum软件组使用

1554195154103

总结:

​ 系统安装原则:最小化安装,用需要用什么软件,就安装什么软件。最好不要卸载软件。更新软件时要注意指定软件名,不然就会更新整个系统(包括内核)。安装时-y 命令要在安装熟练时使用,一般慎用

yum光盘源搭建

15541958110361554196150392

源码包安装管理

源码包和rpm包的区别

​ 安装之前的区别:概念上的区别

​ 安装之后的区别:安装位置不同

1554360805482

1554360845078

​ 由于源码包和rpm 安装包的安装位置不同导致了,应用的启动方式选择面不同

​ rpm 包安装的软件可以 使用 service 去执行命令,也可以使用 绝对路径 + 命令的方法操作

​ 源码包 只能通过 绝对路径 + 命令的方法操作

​ service 操作软件

1
service tomcat start

​ 绝对路径+命令方式

1
/usr/bin/tomcat start

源码包安装过程

1554360911277

1554361918473

源码包安装流程

  1. 下载源码包文件
  2. 解压源码包文件到 /usr/local/ 源码文件名 下
  3. 进入解压目录阅读 INSTALL 文档,查看如何安装。
  4. 使用make 命令编译源码
  5. 使用make install 命令安装

INSTALL安装说明文档

README使用说明

make 编译

make install 编译安装

make clean 清空编译

1554362742757

###脚本安装包

1554368570910

1554368673263

linux-文件配置篇

发表于 2021-12-06 | 更新于 2020-04-03

系统环境

/etc/profile 文件

/etc/profile 文件属于一个系统的全局变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi

if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi

  1. Linux是一个多用户操作系统。用户登录或切换(即Login shell 启动)时都有一个专用的运行环境,但首先执行 /etc/profile 。而Non-login shell不会调用这个脚本。各用户的默认环境(一组环境变量的定义)一般相同。用户也可以自行配置运行环境,即修改相应的系统环境变量。

  2. 在 /etc/profile 文件中设置的变量是全局变量。而 .bashrc文件(在用户的家目录下)则只对当前用户有用

  3. 使用 source 命令更新环境变量。source /etc/profile 或者 ./profile,执行一下文件。但不能用 sh /etc/profile。sh 是在子 shell 进程中执行的,即使PATH改变了也不会反应到当前环境中。而 source 是在当前 shell 进程中执行的,所以我们能看到PATH的改变

4.在profile文件添加或修改的内容需要注销系统才能生效。同名的环境变量,后写入的起作用

quartz-初始

发表于 2021-12-06 | 更新于 2019-09-10

quartz 简介

maven坐标

quartz 快速入门

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();//创建StdSchedulerFactory工厂
Scheduler scheduler = stdSchedulerFactory.getScheduler();

scheduler.start();

JobDetail job = newJob(HelloJob.class)
.withIdentity("myJob","group1")
.build();

Trigger trigger = newTrigger()
.withIdentity("myTrigger","group1")
.startNow()
//调度触发执行内容和时间的操作
.withSchedule(simpleSchedule()
.withIntervalInSeconds(4)
.repeatForever())
.build();
scheduler.scheduleJob(job,trigger);
while (true){}//测试用,防止主线程结束

Quartz 常用接口

Scheduler (与调度程序交)

生命周期

开始:SchedulerFactory 创建后开始
结束:Scheduler调用shutdown结束

Job (调度的内容实现定义)

JobDetail (作业实例)

Trigger (触发器)

公共属性

所有类型的trigger都有TriggerKey这个属性,表示trigger的身份;除此之外,trigger还有很多其它的公共属性。这些属性,在构建trigger的时候可以通过TriggerBuilder设置。

trigger的公共属性有:

jobKey属性:当trigger触发时被执行的job的身份;

startTime属性:设置trigger第一次触发的时间;该属性的值是java.util.Date类型,表示某个指定的时间点;有些类型的trigger,会在设置的startTime时立即触发,有些类型的trigger,表示其触发是在startTime之后开始生效。比如,现在是1月份,你设置了一个trigger–“在每个月的第5天执行”,然后你将startTime属性设置为4月1号,则该trigger第一次触发会是在几个月以后了(即4月5号)。

endTime属性:表示trigger失效的时间点。比如,”每月第5天执行”的trigger,如果其endTime是7月1号,则其最后一次执行时间是6月5号。

优先级(priority)

如果你的trigger很多(或者Quartz线程池的工作线程太少),Quartz可能没有足够的资源同时触发所有的trigger;这种情况下,你可能希望控制哪些trigger优先使用Quartz的工作线程,要达到该目的,可以在trigger上设置priority属性。比如,你有N个trigger需要同时触发,但只有Z个工作线程,优先级最高的Z个trigger会被首先触发。如果没有为trigger设置优先级,trigger使用默认优先级,值为5;priority属性的值可以是任意整数,正数、负数都可以。

注意:只有同时触发的trigger之间才会比较优先级。10:59触发的trigger总是在11:00触发的trigger之前执行。

注意:如果trigger是可恢复的,在恢复后再调度时,优先级与原trigger是一样的。

错过触发描述(misfire instructions)

trigger还有一个重要的属性misfire;如果scheduler关闭了,或者Quartz线程池中没有可用的线程来执行job,此时持久性的trigger就会错过(miss)其触发时间,即错过触发(misfire)。不同类型的trigger,有不同的misfire机制。它们默认都使用“智能机制(smart policy)”,即根据trigger的类型和配置动态调整行为。当scheduler启动的时候,查询所有错过触发(misfire)的持久性trigger。然后根据它们各自的misfire机制更新trigger的信息。当你在项目中使用Quartz时,你应该对各种类型的trigger的misfire机制都比较熟悉,这些misfire机制在JavaDoc中有说明

Simple Trigger

JobBuilder (用于构建JobDetail)

TriggerBuilder (用于构建Trigger)

Scheduler Job Trigger 三者的调用关系

Scheduler 调度计划,如果想要执行调度,需要将Job和Trigger放入
scheduler实例化后,可以启动(start)、暂停(stand-by)、停止(shutdown)注意:scheduler被停止后,除非重新实例化,否则不能重新启动;只有当scheduler启动后,即使处于暂停状态也不行,trigger才会被触发

Job 用来定义工作内容

Trigger用来定义调度的触发时间,以及绑定工作组

JobDataMap的使用

1.Job类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class DumbJob implements Job {

public DumbJob() {
}

public void execute(JobExecutionContext context)
throws JobExecutionException
{
JobKey key = context.getJobDetail().getKey();

JobDataMap dataMap = context.getJobDetail().getJobDataMap();

String jobSays = dataMap.getString("jobSays");
float myFloatValue = dataMap.getFloat("myFloatValue");

System.err.println("Instance " + key + " of DumbJob says: " + jobSays + ", and val is: " + myFloatValue);
}
}

2.调度定义时

1
2
3
4
5
6
// define the job and tie it to our DumbJob class
JobDetail job = newJob(DumbJob.class)
.withIdentity("myJob", "group1") // name "myJob", group "group1"
.usingJobData("jobSays", "Hello World!")
.usingJobData("myFloatValue", 3.141f)
.build();

自动填充jobDataMap参数

只需要修改Job类,在类中添加map相对应的字段提供set方法即可。如下

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
public class DumbJob implements Job {


String jobSays;
float myFloatValue;
ArrayList state;

public DumbJob() {
}

public void execute(JobExecutionContext context)
throws JobExecutionException
{
JobKey key = context.getJobDetail().getKey();

JobDataMap dataMap = context.getMergedJobDataMap(); // Note the difference from the previous example

state.add(new Date());

System.err.println("Instance " + key + " of DumbJob says: " + jobSays + ", and val is: " + myFloatValue);
}

public void setJobSays(String jobSays) {
this.jobSays = jobSays;
}

public void setMyFloatValue(float myFloatValue) {
myFloatValue = myFloatValue;
}

public void setState(ArrayList state) {
state = state;
}

}

@PersistJobDataAfterExecution

由于Job类的创建是由Scheduler上的JobFactory 运行时动态创建的,所以个人猜测框架创作人使用了动态代理的技术。所以Job的成员变量与外界的交互就成为了难题。如何实现呢?答案就是在实现Job的类上加入@PersistJobDataAfterExecution注解,这样JobDataMap中的数据就可以与外界交互了。

@DisallowConcurrentExecution

个人目前还没有使用过,w3cschool的官方文档上是这样介绍的:
1
@DisallowConcurrentExecution:将该注解加到job类上,告诉Quartz不要并发地执行同一个job定义(这里指特定的job类)的多个实例

web认证机制

发表于 2021-12-06 | 更新于 2019-04-29

HTTP Basic Auth

​ HTTP Basic Auth简单点说明就是每次请求API时都提供用户的username和password,简言之,Basic Auth是配合
RESTful API 使用的最简单的认证方式,只需提供用户名密码即可,但由于有把用户名密码暴露给第三方客户端的风险,在生产环境下被使用的越来越少。因此,在开发对外开放的RESTful API时,尽量避免采用HTTP Basic Auth

个人观点:简单易于实现,安全性低

Cookie Auth

​ Cookie认证机制就是为一次请求认证在服务端创建一个Session对象,同时在客户端的浏览器端创建了一个Cookie
对象;通过客户端带上来Cookie对象来与服务器端的session对象匹配来实现状态管理的。默认的,当我们关闭浏览器的时候,cookie会被删除。但可以通过修改cookie 的expire time使cookie在一定时间内有效

个人观点:可以使应用认证有状态性,要想保证认证的有状态性使得服务器的session频繁创建,会对服务器的开销增加压力。安全性:一般

OAuth

​ OAuth(开放授权)是一个开放的授权标准,允许用户让第三方应用访问该用户在某一web服务上存储的私密的资
源(如照片,视频,联系人列表),而无需将用户名和密码提供给第三方应用。 OAuth允许用户提供一个令牌,而不是用户名和密码来访问他们存放在特定服务提供者的数据。每一个令牌授权一个特定的第三方系统(例如,视频编辑网站)在特定的时段(例如,接下来的2小时内)内访问特定的资源(例如仅仅是某一相册中的视频)。这样,OAuth让用户可以授权第三方网站访问他们存储在另外服务提供者的某些特定信息,而非所有内容这种基于OAuth的认证机制适用于个人消者类的互联网产品,如社交类APP等应用,但是不太适合拥有自有认证权限管理的企业应用。

个人观点:安全性高。OAuth让用户可以授权第三方网站访问他们存储在另外服务提供者的某些特定信息,而非所有内容这种基于OAuth的认证机制适用于个人消者类的互联网产品,如社交类APP等应用,但是不太适合拥有自有认证权限管理的企业应用。

Token Auth

使用基于 Token 的身份验证方法,在服务端不需要存储用户的登录记录。大概的流程是这样的:

  1. 客户端使用用户名跟密码请求登录
  2. 服务端收到请求,去验证用户名与密码
  3. 验证成功后,服务端会签发一个 Token,再把这个 Token 发送给客户端
  4. 客户端收到 Token 以后可以把它存储起来,比如放在 Cookie 里
  5. 客户端每次向服务端请求资源的时候需要带着服务端签发的 Token
  6. 服务端收到请求,然后去验证客户端请求里面带着的 Token,如果验证成功,就向客户端返回请求的数据

Token Auth的优点

​ 支持跨域访问: Cookie是不允许垮域访问的,这一点对Token机制是不存在的,前提是传输的用户认证信息通过HTTP头传输.
无状态(也称:服务端可扩展行):Token机制在服务端不需要存储session信息,因为Token 自身包含了所有登录用户的信息,只需要在客户端的cookie或本地介质存储状态信息.
更适用CDN: 可以通过内容分发网络请求你服务端的所有资料(如:javascript,HTML,图片等),而你的服务端只要提供API即可.
去耦: 不需要绑定到一个特定的身份验证方案。Token可以在任何地方生成,只要在你的API被调用的时候,你可以进行Token生成调用即可.
更适用于移动应用: 当你的客户端是一个原生平台(iOS, Android,Windows 8等)时,Cookie是不被支持的(你需要通过Cookie容器进行处理),这时采用Token认证机制就会简单得多。
CSRF:因为不再依赖于Cookie,所以你就不需要考虑对CSRF(跨站请求伪造)的防范。
性能: 一次网络往返时间(通过数据库查询session信息)总比做一次HMACSHA256计算 的Token验证和解析要费时得多.
不需要为登录页面做特殊处理: 如果你使用Protractor 做功能测试的时候,不再需要为登录页面做特殊处理.
基于标准化:你的API可以采用标准化的 JSON Web Token (JWT). 这个标准已经存在多个后端库(.NET, Ruby,
Java,Python, PHP)和多家公司的支持(如:Firebase,Google, Microsoft).

python带我飞-note

发表于 2021-12-06 | 更新于 2019-09-18

第二篇 进阶

变量

变量是编程语言中最基础的术语,用来指计算机中存储的可变数据。如下例子

1
Val = "hello"

变量的规则

类型不同,存储功能不同

申明变量无需定义变量类型,直接赋值即可

如何做到直接赋值,原因是Python内部对变量进行了对象封装,并且它具有三个重要的属性id,type,value

变量的类型

Python3中的类型划分为6种:

number 数字可以划分为 int float bool complex 等

string 字符串

tuple 元组

sets 集合

dictionaries 字典

变量类型的帮助函数

dir 用来查询类型的所有属性。如dir(number)

help 用来查询类型具体的说明文档。如help(number)

ssh协议

发表于 2021-12-06 | 更新于 2019-08-23

Http headers

if-modified-since

首先他是一个条件式头部信息

个人认为它用来标识修改的时间,时间指的是上次响应头中的last-modified的时间

if-match

首先它是一个条件式头部信息

GET方式的请求中使用它后,服务器会验证ETag是否匹配,如果不匹配则不返回数据

PUT等不安全的方法判断同上,不同之处在于不能上传数据或修改数据

它们比较的算法默认为强比较算法,也就是对比每一个比特位,都相同时认为文件或信息是相同的。如果在ETag前加入“w/”那么比较的算法就会由强比较改为相对宽松的算法

maven

发表于 2021-12-06 | 更新于 2022-11-18

maven介绍

什么是maven

Maven 的正确发音是[ˈmevən],而不是“马瘟”以及其他什么瘟。Maven 在美国是一个口语化的词
语,代表专家、内行的意思。

maven 是一个项目管理工具,它包含了一个项目对象模型(pom:project object model)一组标准集合,一个项目生命周期(project Lifecycle),一个依赖管理系统(dependency management system)和用来运行定义在生命周期阶段中插件目标的逻辑

maven 能做什么

1.引入jar包,可控制jar包冲突问题
2.编译(java文件编译为字节码)
3.运行测试用例
4.打包

maven 的特点

依赖管理

根据pom中的坐标将jar包导入项目中,可以做到jar包的复用。
如将一个junit导入项目使用maven则体现为
1
2
3
4
5
6
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
依赖传递

下面从字面依赖和传递两个方面了解依赖传递的概念

依赖:项目A中引入了项目B,这时我们就可以说A依赖于B

传递:项目B中依赖了项目C由于A依赖于B,所以根据依赖的关系A也就依赖了项目C

maven的依赖传递可以方便引入一些项目,但是存在一个问题就是如果一个项目同时依赖2个项目。而依赖的2个项目分别又依赖同一个项目的不同版本。这里由于版本的不同可能会引发一些兼容性问题。我们把这种情况称之为依赖传递冲突。

maven对这种冲突提供的解决方案如下:

依赖调节原则:

1、第一声明者优先原则:在 pom 文件定义依赖,先声明的依赖为准。
2、路径近者优先原则:例如:A项目依赖B B依赖C C又依赖D 如果我们在A中申明依赖D的不同版本,那么A项目就会依赖D的声明版本而不是传递的D版本。

只要我们遵循原则maven会帮我们自动处理依赖 ,但我们如果不想遵循原则就不能解决冲突了吗?答案肯定是可以,毕竟maven是一款优秀的自动化构建工具

不遵循原则如何解决冲突:

1.排除依赖

1
2
3
4
5
6
7
8
9
10
11
<dependency>
<groupId>com.itcast.ssm</groupId>
<artifactId>ssm_service</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>XXX</groupId>
<artifactId>XXX</artifactId>
</exclusion>
</exclusions>
</dependency>

2.锁定版本

1
2
3
4
5
6
7
8
9
10
 <dependencyManagement>
<dependencies>
<!-- Mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

3.可选依赖
当坐标被赋予

1
<optional>true</optional>

时此坐标不会被传递依赖。

example:

1
2
3
4
5
6
7
8
9
10
11
 <dependencyManagement>
<dependencies>
<!-- Mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</dependencyManagement>

一键构建

maven 规范化流程如下图


一键构建是指,如果用户需要实现上述流程中的清理,只需要使用maven自带的mvn clean命令即可完成项目的清空。
如果是实现流程中的打包,则使用命令mvn package 即可,并且它还会执行打包前的所有流程项。

maven 安装后目录解析

bin:存放了 maven 的命令,比如我们前面用到的 mvn tomcat:run
boot:存放了一些 maven 本身的引导程序,如类加载器等
conf:存放了 maven 的一些配置文件,如 setting.xml 文件
lib:存放了 maven 本身运行所需的一些 jar 包
在使用maven前电脑需安装jdk或jre因为maven是用java编写的

maven 命令

查看maven的帮助信息

1
spiderbao@spiderbao-CW65S:~$ mvn -help

maven 查看版本信息

1
2
3
4
5
6
7
spiderbao@spiderbao-CW65S:~$ mvn -v
Apache Maven 3.6.0
Maven home: xxx
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: xxx
java-8-openjdk-amd64/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-18-generic", arch: "amd64", family: "unix"

compile 编译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
spiderbao@spiderbao-CW65S:~/idea_dev/hello_maven$ mvn complie
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.itheima:hello_maven >-----------------------
[INFO] Building hello_maven Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.145 s
[INFO] Finished at: 2019-05-08T14:24:23+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "complie". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException

mvn complie 打错 改为 compile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
spiderbao@spiderbao-CW65S:~/idea_dev/hello_maven$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.itheima:hello_maven >-----------------------
[INFO] Building hello_maven Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello_maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/spiderbao/idea_dev/hello_maven/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hello_maven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/spiderbao/idea_dev/hello_maven/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.307 s
[INFO] Finished at: 2019-05-08T14:26:40+08:00
[INFO] ------------------------------------------------------------------------

test 测试

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
spiderbao@spiderbao-CW65S:~/idea_dev/hello_maven$ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.itheima:hello_maven >-----------------------
[INFO] Building hello_maven Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello_maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/spiderbao/idea_dev/hello_maven/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hello_maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hello_maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/spiderbao/idea_dev/hello_maven/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hello_maven ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello_maven ---
[INFO] No tests to run.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.072 s
[INFO] Finished at: 2019-05-08T14:27:10+08:00
[INFO] ------------------------------------------------------------------------

由于没有写测试用例所以No tests to run.
clean 清空

1
2
3
4
5
6
7
8
9
10
11
12
13
14
spiderbao@spiderbao-CW65S:~/idea_dev/hello_maven$ mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.itheima:hello_maven >-----------------------
[INFO] Building hello_maven Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hello_maven ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.289 s
[INFO] Finished at: 2019-05-08T14:23:21+08:00
[INFO] ------------------------------------------------------------------------

package 打包

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
spiderbao@spiderbao-CW65S:~/idea_dev/hello_maven$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.itheima:hello_maven >-----------------------
[INFO] Building hello_maven Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello_maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/spiderbao/idea_dev/hello_maven/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hello_maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hello_maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/spiderbao/idea_dev/hello_maven/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hello_maven ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello_maven ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ hello_maven ---
[INFO] Packaging webapp
[INFO] Assembling webapp [hello_maven] in [/home/spiderbao/idea_dev/hello_maven/target/hello_maven]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/spiderbao/idea_dev/hello_maven/src/main/webapp]
[INFO] Webapp assembled in [22 msecs]
[INFO] Building war: /home/spiderbao/idea_dev/hello_maven/target/hello_maven.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.515 s
[INFO] Finished at: 2019-05-08T14:28:25+08:00

install 安装

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
spiderbao@spiderbao-CW65S:~/idea_dev/hello_maven$ mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.itheima:hello_maven >-----------------------
[INFO] Building hello_maven Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello_maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/spiderbao/idea_dev/hello_maven/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hello_maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hello_maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/spiderbao/idea_dev/hello_maven/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hello_maven ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello_maven ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ hello_maven ---
[INFO] Packaging webapp
[INFO] Assembling webapp [hello_maven] in [/home/spiderbao/idea_dev/hello_maven/target/hello_maven]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/spiderbao/idea_dev/hello_maven/src/main/webapp]
[INFO] Webapp assembled in [23 msecs]
[INFO] Building war: /home/spiderbao/idea_dev/hello_maven/target/hello_maven.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ hello_maven ---
[INFO] Installing /home/spiderbao/idea_dev/hello_maven/target/hello_maven.war to /home/spiderbao/.m2/repository/com/itheima/hello_maven/1.0-SNAPSHOT/hello_maven-1.0-SNAPSHOT.war
[INFO] Installing /home/spiderbao/idea_dev/hello_maven/pom.xml to /home/spiderbao/.m2/repository/com/itheima/hello_maven/1.0-SNAPSHOT/hello_maven-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.604 s
[INFO] Finished at: 2019-05-08T14:42:26+08:00
[INFO] ------------------------------------------------------------------------

maven 库

maven库可以分为3类分别是:

本地仓库

本地仓库 :用来存储从远程仓库或中央仓库下载的插件和 jar 包,项目使用一些插件或 jar 包,

优先从本地仓库查找

远程仓库

远程仓库:如果本地需要插件或者 jar 包,本地仓库没有,默认去远程仓库下载。

远程仓库可以在互联网内也可以在局域网内。

中央仓库

中央仓库 :在 maven 软件中内置一个远程仓库地址 http://repo1.maven.org/maven2 ,它是中

央仓库,服务于整个互联网,它是由 Maven 团队自己维护,里面存储了非常全的 jar 包,它包
含了世界上大部分流行的开源项目构件。

setting

setting 文件主要用来配置maven的一些仓库设置,如本地仓库,远程仓库等。

全局setting 和用户 setting

在 maven 安装目录下的有 conf/setting.xml 文件,此 setting.xml 文件用于 maven 的所有 project
项目,它作为 maven 的全局配置。
如需要个性配置则需要在用户配置中设置,用户配置的 setting.xml 文件默认的位置在: ${user.dir}
/.m2/settings.xml 目录中,${user.dir} 指 windows 中的用户目录。或在项目中添加setting.xml
maven 会先找用户配置,如果找到则以用户配置文件为准,否则使用全局配置文件。

maven 工程认识

maven 工程的目录结构如下图

作为一个 maven 工程,它的 src 目录和 pom.xml 是必备的。
进入 src 目录后,我们发现它里面的目录结构如下:

src/main/java —— 存放项目的.java 文件
src/main/resources —— 存放项目资源文件,如 spring, hibernate 配置文件
src/test/java —— 存放所有单元测试.java 文件,如 JUnit 测试类
src/test/resources —— 测试资源文件
target —— 项目输出位置,编译后的 class 文件会输出到此目录
pom.xml——maven 项目核心配置文件
注意:如果是普通的 java 项目,那么就没有 webapp 目录。

maven 指令的生命周期

maven 对项目构建过程分为三套相互独立的生命周期,请注意这里说的是“三套”,而且“相互独立”,
这三套生命周期分别是:

Clean Lifecycle 在进行真正的构建之前进行一些清理工作。
Default Lifecycle 构建的核心部分,编译,测试,打包,部署等等。
Site Lifecycle 生成项目报告,站点,发布站点

maven 概念模型

Maven 包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project
Lifecycle),一个依赖管理系统(Dependency Management System),和用来运行定义在生命周期阶段
(phase)中插件(plugin)目标(goal)的逻辑。

项目对象模型 (Project Object Model)
一个 maven 工程都有一个 pom.xml 文件,通过 pom.xml 文件定义项目的坐标、项目依赖、项目信息、
插件目标等。

依赖管理系统(Dependency Management System)
通过 maven 的依赖管理对项目所依赖的 jar 包进行统一管理。
比如:项目依赖 junit4.9,通过在 pom.xml 中定义 junit4.9 的依赖即使用 junit4.9,如下所示是 junit4.9
的依赖定义:

1
2
3
4
5
6
7
8
9
10
11
12
13
<!-- 依赖关系 -->
<dependencies>
<!-- 此项目运行使用 junit,所以此项目依赖 junit -->
<dependency>
<!-- junit 的项目名称 -->
<groupId>junit</groupId>
<!-- junit 的模块名称 -->
<artifactId>junit</artifactId>
<!-- junit 版本 -->
<version>4.9</version>
<!-- 依赖范围:单元测试时使用 junit -->
<scope>test</scope>
</dependency>

一个项目生命周期(Project Lifecycle)
使用 maven 完成项目的构建,项目构建包括:清理、编译、测试、部署等过程,maven 将这些
过程规范为一个生命周期,如下所示是生命周期的各各阶段:

maven 通过执行一些简单命令即可实现上边生命周期的各各过程,比如执行 mvn compile 执行编译、
执行 mvn clean 执行清理。

一组标准集合
maven 将整个项目管理过程定义一组标准,比如:通过 maven 构建工程有标准的目录结构,有
标准的生命周期阶段、依赖管理有标准的坐标定义等。

插件(plugin)目标(goal)
maven 管理项目生命周期过程都是基于插件完成的

maven的继承和聚合

maven的继承

继承后maven的子模块会拥有父模块的所有pom信息

1
2
3
4
5
<parent>
<artifactId>ssm_parent</artifactId>
<groupId>com.itcast.ssm</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

maven的聚合

我把maven的聚合看做,一个pom件就可以构建指定模块并组合成为一个项目

maven 坐标的来源方式

坐标搜索网站

central or mvnrepository

maven 私服搭建及其使用

maven私服搭建

下载nexus安装包

1
2
3
  $  cd /opt

  $  wget http://download.sonatype.com/nexus/oss/nexus-2.10.0-02-bundle.tar.gz

解压并安装

1
2
3
4
5
6
7
  $  cd /opt/

  $  tar -zxvf nexus-2.10.0-02-bundle.tar.gz

  $  cd /opt/nexus-2.10.0-02/bin

  $  vim nexus

在 nexus文件中添加RUN_AS_USER用户如下

1
RUN_AS_USER=root

启动nexus

1
 $  ./nexus start

nexus 配置解析:

查看 nexus 的配置文件 conf/nexus.properties

1
2
3
4
5
6
7
8
9
10
11
# Jetty section
application-port=8081 # nexus 的访问端口配置
application-host=0.0.0.0 # nexus 主机监听配置(不用修改)
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
# nexus 工程目录
# nexus 的 web 访问路径
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
# nexus 仓库目录
runtime=${bundleBasedir}/nexus/WEB-INF # nexus 运行程序目录

nexus仓库类型

nexus 的仓库有 4 种类型:

1.hosted,宿主仓库,部署自己的 jar 到这个类型的仓库,包括 releases 和 snapshot 两部分,Releases 公司内部发布版本仓库、 Snapshots 公司内部测试版本仓库

2.proxy,代理仓库,用于代理远程的公共仓库,如 maven 中央仓库,用户连接私服,私服自动去中央仓库下载 jar 包或者插件。

3.group,仓库组,用来合并多个 hosted/proxy 仓库,通常我们配置自己的 maven 连接仓库组。

4.virtual(虚拟):兼容 Maven1 版本的 jar 或者插件

nexus 仓库默认在 sonatype-work 目录中

将项目发布到私服

1.setting配置添加 server

1
2
3
4
5
6
7
8
9
10
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>

2.项目pom添加仓库

1
2
3
4
5
6
7
8
9
10
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

3.使用maven命令发布

1
mvn deploy

maven 配置私服下载jar包

没有配置nexus之前,如果本地仓库没有,去中央仓库下载,通常在企业中会在局域网
内部署一台私服服务器,有了私服本地项目首先去本地仓库找 jar,如果没有找到则连接私
服从私服下载 jar 包,如果私服没有 jar 包私服同时作为代理服务器从中央仓库下载 jar 包,
这样做的好处是一方面由私服对公司项目的依赖 jar 包统一管理,一方面提高下载速度,项
目连接私服下载 jar 包的速度要比项目连接中央仓库的速度快的多。

setting配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<profile>
<!--仓库id-->
<id>dev</id>
<repositories>
<repository>
<!--仓库 id,repositories 可以配置多个仓库,保证 id 不重复-->
<id>nexus</id>
<!--仓库地址,即 nexus 仓库组的地址-->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>

<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>

将第三方jar导入本地maven

1
2
mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37
-Dfile= fastjson-1.1.37.jar -Dpackaging=jar

参数说明
DgroupId 和 DartifactId 构成了该 jar 包在 pom.xml 的坐标,项目就是依靠这两个属性定位。
自己起名字也行。
Dfile 表示需要上传的 jar 包的绝对路径。
Durl 私服上仓库的位置,打开 nexus——>repositories 菜单,可以看到该路径。
DrepositoryId 服务器的表示 id,在 nexus 的 configuration 可以看到。
Dversion 表示版本信息

将第三方jar导入私服

1.在setting中配置第三方server

1
2
3
4
5
<server>
<id>thirdparty</id>
<username>admin</username>
<password>admin123</password>
</server>

1
2
3
4
mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37
-Dpackaging=jar -Dfile=fastjson-1.1.37.jar
-Durl=http://localhost:8081/nexus/content/repositories/thirdparty/
-DrepositoryId=thirdparty

参数说明
DgroupId 和 DartifactId 构成了该 jar 包在 pom.xml 的坐标,项目就是依靠这两个属性定位。
自己起名字也行。
Dfile 表示需要上传的 jar 包的绝对路径。
Durl 私服上仓库的位置,打开 nexus——>repositories 菜单,可以看到该路径。
DrepositoryId 服务器的表示 id,在 nexus 的 configuration 可以看到。
Dversion 表示版本信息

windows 上搭建nexus

下载连接

解压到系统盘符下

安装nexus

nexus 的目录结构如下

├─nexus-2.10.0-02
│ ├─bin
│ │ └─jsw
│ │ ├─conf
│ │ ├─lib
│ │ ├─license
│ │ ├─linux-ppc-64
│ │ ├─linux-x86-32
│ │ ├─linux-x86-64
│ │ ├─macosx-universal-32
│ │ ├─macosx-universal-64
│ │ ├─solaris-sparc-32
│ │ ├─solaris-sparc-64
│ │ ├─solaris-x86-32
│ │ │ └─sample-smf
│ │ ├─windows-x86-32
│ │ └─windows-x86-64
│ ├─conf
│ ├─lib
│ ├─logs
│ ├─nexus
│ │ ├─images
│ │ └─WEB-INF
│ │ ├─bundles
│ │ ├─classes
│ │ │ ├─META-INF
│ │ │ │ └─sisu
│ │ │ └─org
│ │ │ └─sonatype
│ │ │ └─nexus
│ │ │ └─webapp
│ │ │ └─metrics
│ │ ├─lib
│ │ └─plugin-repository
│ │ ├─nexus-analytics-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-archetype-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-atlas-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-capabilities-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-content-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-crypto-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-groovy-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-h2-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-healthcheck-oss-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-indexer-lucene-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-kazuki-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-ldap-realm-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-logging-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-lvo-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-maven-bridge-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-npm-repository-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-nuget-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-outreach-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-plugin-console-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-restlet1x-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-rrb-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-rutauth-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-siesta-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-site-repository-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-timeline-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ ├─nexus-ui-extjs3-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-webresources-plugin-2.10.0-02
│ │ │ └─META-INF
│ │ ├─nexus-wonderland-plugin-2.10.0-02
│ │ │ ├─dependencies
│ │ │ └─META-INF
│ │ └─nexus-yum-repository-plugin-2.10.0-02
│ │ ├─dependencies
│ │ └─META-INF
│ └─tmp
│ ├─jetty-0.0.0.0-8081-nexus-_nexus-any-
│ ├─jna–1833998801
│ ├─nexus-ehcache
│ └─outreach
└─sonatype-work
└─nexus
├─conf
├─db
│ ├─analytics
│ └─npm
├─felix-cache
│ ├─bundle0
│ ├─bundle1
│ │ └─version0.0
│ ├─bundle10
│ │ └─version0.0
│ │ └─nexus-restlet1x-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-restlet1x-plugin-2.10.0-02.jar
│ ├─bundle11
│ │ └─version0.0
│ │ └─nexus-plugin-console-plugin-2.10.0-02-embedded
│ │ └─nexus-plugin-console-plugin-2.10.0-02.jar
│ ├─bundle12
│ │ └─version0.0
│ │ └─nexus-timeline-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-timeline-plugin-2.10.0-02.jar
│ ├─bundle13
│ │ └─version0.0
│ │ └─nexus-h2-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-h2-plugin-2.10.0-02.jar
│ ├─bundle14
│ │ └─version0.0
│ │ └─nexus-kazuki-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-kazuki-plugin-2.10.0-02.jar
│ ├─bundle15
│ │ └─version0.0
│ │ └─nexus-capabilities-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-capabilities-plugin-2.10.0-02.jar
│ ├─bundle16
│ │ └─version0.0
│ │ └─nexus-outreach-plugin-2.10.0-02-embedded
│ │ └─nexus-outreach-plugin-2.10.0-02.jar
│ ├─bundle17
│ │ └─version0.0
│ │ └─nexus-rrb-plugin-2.10.0-02-embedded
│ │ └─nexus-rrb-plugin-2.10.0-02.jar
│ ├─bundle18
│ │ └─version0.0
│ │ └─nexus-indexer-lucene-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-indexer-lucene-plugin-2.10.0-02.jar
│ ├─bundle19
│ │ └─version0.0
│ │ └─nexus-analytics-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-analytics-plugin-2.10.0-02.jar
│ ├─bundle2
│ │ └─version0.0
│ │ └─nexus-webresources-plugin-2.10.0-02-embedded
│ │ └─nexus-webresources-plugin-2.10.0-02.jar
│ ├─bundle20
│ │ └─version0.0
│ │ └─nexus-npm-repository-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-npm-repository-plugin-2.10.0-02.jar
│ ├─bundle21
│ │ └─version0.0
│ │ └─nexus-yum-repository-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-yum-repository-plugin-2.10.0-02.jar
│ ├─bundle22
│ │ └─version0.0
│ │ └─nexus-site-repository-plugin-2.10.0-02-embedded
│ │ └─nexus-site-repository-plugin-2.10.0-02.jar
│ ├─bundle23
│ │ └─version0.0
│ │ └─nexus-lvo-plugin-2.10.0-02-embedded
│ │ └─nexus-lvo-plugin-2.10.0-02.jar
│ ├─bundle24
│ │ └─version0.0
│ │ └─nexus-healthcheck-oss-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-healthcheck-oss-plugin-2.10.0-02.jar
│ ├─bundle25
│ │ └─version0.0
│ │ └─nexus-ldap-realm-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-ldap-realm-plugin-2.10.0-02.jar
│ ├─bundle26
│ │ └─version0.0
│ │ └─nexus-maven-bridge-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-maven-bridge-plugin-2.10.0-02.jar
│ ├─bundle27
│ │ └─version0.0
│ │ └─nexus-nuget-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-nuget-plugin-2.10.0-02.jar
│ ├─bundle28
│ │ └─version0.0
│ │ └─nexus-logging-plugin-2.10.0-02-embedded
│ │ └─nexus-logging-plugin-2.10.0-02.jar
│ ├─bundle29
│ │ └─version0.0
│ │ └─nexus-rutauth-plugin-2.10.0-02-embedded
│ │ └─nexus-rutauth-plugin-2.10.0-02.jar
│ ├─bundle3
│ │ └─version0.0
│ │ └─nexus-ui-extjs3-plugin-2.10.0-02-embedded
│ │ └─nexus-ui-extjs3-plugin-2.10.0-02.jar
│ ├─bundle30
│ │ └─version0.0
│ │ └─nexus-archetype-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-archetype-plugin-2.10.0-02.jar
│ ├─bundle4
│ │ └─version0.0
│ │ └─nexus-siesta-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-siesta-plugin-2.10.0-02.jar
│ ├─bundle5
│ │ └─version0.0
│ │ └─nexus-crypto-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-crypto-plugin-2.10.0-02.jar
│ ├─bundle6
│ │ └─version0.0
│ │ └─nexus-groovy-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-groovy-plugin-2.10.0-02.jar
│ ├─bundle7
│ │ └─version0.0
│ │ └─nexus-wonderland-plugin-2.10.0-02-embedded
│ │ ├─dependencies
│ │ └─nexus-wonderland-plugin-2.10.0-02.jar
│ ├─bundle8
│ │ └─version0.0
│ │ └─nexus-atlas-plugin-2.10.0-02-embedded
│ │ └─nexus-atlas-plugin-2.10.0-02.jar
│ └─bundle9
│ └─version0.0
│ └─nexus-content-plugin-2.10.0-02-embedded
│ └─nexus-content-plugin-2.10.0-02.jar
├─health-check
├─indexer
│ ├─apache-snapshots-ctx
│ ├─central-ctx
│ ├─codehaus-snapshots-ctx
│ ├─public-ctx
│ ├─releases-ctx
│ ├─snapshots-ctx
│ └─thirdparty-ctx
├─logs
├─nuget
├─plugin-repository
├─storage
│ ├─apache-snapshots
│ │ ├─.meta
│ │ └─.nexus
│ │ ├─attributes
│ │ │ └─.meta
│ │ └─tmp
│ ├─central
│ │ ├─.meta
│ │ └─.nexus
│ │ ├─attributes
│ │ │ └─.meta
│ │ └─tmp
│ ├─central-m1
│ │ ├─.meta
│ │ └─.nexus
│ │ ├─attributes
│ │ │ └─.meta
│ │ └─tmp
│ ├─codehaus-snapshots
│ │ ├─.meta
│ │ └─.nexus
│ │ ├─attributes
│ │ │ └─.meta
│ │ └─tmp
│ ├─public
│ │ ├─.meta
│ │ └─.nexus
│ │ ├─attributes
│ │ │ └─.meta
│ │ └─tmp
│ ├─releases
│ │ ├─.meta
│ │ └─.nexus
│ │ ├─attributes
│ │ │ └─.meta
│ │ └─tmp
│ ├─snapshots
│ │ ├─.meta
│ │ └─.nexus
│ │ ├─attributes
│ │ │ └─.meta
│ │ └─tmp
│ └─thirdparty
│ ├─.meta
│ └─.nexus
│ ├─attributes
│ │ └─.meta
│ └─tmp
└─timeline
├─index
└─persist

以管理员权限打开cmd窗口,进入如下目录 nexus-2.10.0-02\bin\jsw\windows-x86-64 然后运行install-nexus.bat 文件进行安装。效果如下图

运行nexus

运行start-nexus.bat

然后访问http://localhost:8081/nexus/#welcome,出现如下效果就安装成功了

webGlDay01

发表于 2021-12-06 | 更新于 2019-06-27

WebGL 简介

webgl是一项可以在浏览器中流畅展示3D模型和场景的一种技术。
它使用JavaScript作为编程语言,调用浏览器支持的3D绘制函数,来实现3D模型和场景的展现。

为什么浏览器可以实现3D绘制

因为浏览器实现了opengl es的规范,这套规范可以直接使用指令操作显卡,使显卡渲染3D世界,直接反应到浏览器中。

操作流程: JavaScript ——> opengl es ——> 显卡

webgl可以做什么

只要涉及到3D都有webgl的用武之地。比如游戏、家居、城市地图

webgl之three.js

three.js是什么

three.js是一个封装好的webgl库,使用它可以更便捷的使用webgl.

123…7
WenLiangBao

WenLiangBao

个人技术总结。(*^_^*)温故而知新,可以为师矣

62 日志
7 标签
Creative Commons
© 2024 WenLiangBao
由 Hexo 强力驱动 v3.8.0
|
主题 – NexT.Mist v7.0.0