搭建maven私服
maven
maven简介
什么是maven?
Maven这个单词来自于意第绪语(犹太语),意为知识的积累。
Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的项目管理工具软件。
Maven 除了以程序构建能力为特色之外,还提供高级项目管理工具。由于 Maven 的缺省构建规则有较高的可重用性,所以常常用两三行 Maven 构建脚本就可以构建简单的项目。由于 Maven 的面向项目的方法,许多 Apache Jakarta 项目发文时使用 Maven,而且公司项目采用 Maven 的比例在持续增长。
maven发展历史
maven的体系结构
maven安装配置
maven下载与配置
下载maven
访问网站 https://maven.apache.org


maven本地配置
打开conf\settings.xml文件
本地仓库位置
配置本地仓库的位置
<localRepository> 本地地址 <localRepository>
<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| The path to the local repository maven will use to store artifacts.|| Default: ${user.home}/.m2/repository--><localRepository>C:\maven-repository</localRepository>
镜像配置
由于中央仓库在境外,网络访问不稳定,故在开发过程中大多配置中央仓库的镜像仓库。
<mirror><id>aliyunmaven</id><mirrorOf>central</mirrorOf><name>阿里云公共仓库</name><url>https://maven.aliyun.com/repository/public</url>
</mirror>
profile
配置maven默认使用的jdk环境。
<profile><id>jdk-1.8</id><activation><activeByDefault>true</activeByDefault><jdk>1.8</jdk> </activation><properties><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion></properties>
</profile>
idea环境安装配置maven
在idea中打开File/Settings
配置本地maven


maven核心思想
maven仓库
maven生命周期
maven项目对象模型(pom)
dependency
依赖Scope配置。
序列 | 依赖范围(Scope) | 对于主代码classpath有效 | 对于测试代码classpath有效 | 被打包,对于运行时classpath有效 | 案例 |
---|---|---|---|---|---|
1 | compile | yes | yes | yes | log4j |
2 | test | yes | junit | ||
3 | provided | yes | yes | servlet-api | |
4 | runtime | yes | JDBC Driver Implementtion |
maven私服-nexus
下载安装
下载nexus
访问官网: https://help.sonatype.com/repomanager3/product-information/download
由于网络不稳定,下载问题,我选择其它版本nexus-3.40.1-01-unix.tar.gz
上传到linux服务器
解压并重名名
解压nexus-3.40.1-01-unix.tar.gz
tar -zxvf nexus-3.40.1-01-unix.tar.gz

nexus配置
进入nexus-3.40.1/bin文件夹

编辑nexus.vmoptions文件
根据自己机器内存大小,适当配置内存。内存太小未来启动nexus会失败。
vim nexus.vmoptions

配置端口
默认端口为8081,如果需要在要在文件中配置端口。(如果不需改端口,此处可以忽略)
-
进入etc文件夹
-
修改nexus-default.properties文件
运行nexus
启动nexus
运行命令**./nexus start**

开放linux的8081端口
-
检查系统开放的端口号
firewall-cmd --list-ports
-
添加8081端口
firewall-cmd --zone=public --add-port=端口号/tcp --permanent
-
重新加载防火墙
firewall-cmd --reload
查看nexus的运行状态
在浏览器中输入http://102.168.0.101:8081
修改管理员密码
-
查看管理员账户密码
-
进入sonatype-work\nexus3文件夹
-
查看管理员密码
-
-
修改管理员密码
-
浏览器登录nexus
-
修改密码
-
配置私有仓库
nexus中默认仓库
maven-releases (Version policy=Release)默认只允许上传不带SNAPSHOT版本尾缀的包,默认部署策略是Disable redeploy 不允许重复上传相同版本号信息的jar,避免包版本更新以后使用方无法获取到最新的包。
maven-snapshots (Version policy=Snapshot)只允许上传带SNAPSHOT版本尾缀的包,默认部署策略是Allow redeploy,允许重复上传相同版本号信息的jar,每次上传的时候会在jar的版本号上面增加时间后缀信息。
maven-central 中央仓库的拷贝,如果环境可以访问中央仓库,则可以获取到相关的包,否则没用
maven-public 仓库组,不是实际个一个仓库地址,只是将现有的组合到一次,可以通过它看到所属组内全部仓库的jar信息
创建自定义仓库
选择maven2(hosted)
添加新建仓库到maven-public群组中
-
选中maven-public群组,之后访问maven-public就可以访问自己的私有仓库了。
-
创建三个仓库,wnhz-repository(混合拍照&发布), wnhz-releases(发布版), wnhz-snapshots(拍照班)
照片版(测试版/开发版)
发布版
混合版
-
添加仓库到群组maven-public群组中
批量上传本地文件到自定义仓库中
上传本地仓库内容到linux服务器

编辑批量上传脚本
在本地仓库上传的文件夹(maven-repository)下创建一个shell脚本,命名 localrepository.sh
-
创建脚本
touch localrepository.sh
-
编辑脚本
vim localrepository.sh
#!/bin/bash while getopts ":r:u:p:" opt; docase $opt inr) REPO_URL="$OPTARG";;u) USERNAME="$OPTARG";;p) PASSWORD="$OPTARG";;esac donefind . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;
添加权限
给脚本localrepository.sh添加执行权限
chmod +x localrepository.sh

导入本地仓库到nexus私有仓库
执行以下命令
./localrepository.sh -u nexus用户名 -p nexus密码 -r 仓库地址(自定义存储混合依赖的)
./localrepository.sh -u admin -p 123 -r http://192.168.198.128:8081/repository/wnhz-repository/
项目中引用nexus库
在maven的conf/settings.xml中配置server
在settings中配置snapshots,releases和wnhz-repository服务用户名密码
注意:id必须唯一,项目pom中引用的是这个指定id。
<servers><!-- server| Specifies the authentication information to use when connecting to a particular server, identified by| a unique name within the system (referred to by the 'id' attribute below).|| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are| used together.|<server><id>deploymentRepo</id><username>repouser</username><password>repopwd</password></server>--><!-- Another sample, using keys to authenticate.<server><id>siteServer</id><privateKey>/path/to/private/key</privateKey><passphrase>optional; leave empty if not used.</passphrase></server>--><server><id>wnhz</id><username>admin</username><password>123</password></server><server><id>wnhz-release</id><username>admin</username><password>123</password></server><server><id>wnhz-snapshots</id><username>admin</username><password>123</password></server></servers>
在maven中配置镜像
中央仓库的资源从阿里云访问,其它资源来自nexus私服。
<mirrors><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors. <mirror><id>mirrorId</id><mirrorOf>repositoryId</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://my.repository.com/repo/path</url></mirror>--><mirror><id>aliyunmaven</id><mirrorOf>central</mirrorOf><name>阿里云公共仓库</name><url>https://maven.aliyun.com/repository/public</url></mirror><mirror><id>wnhzmaven</id><mirrorOf>*</mirrorOf><name>蜗牛杭州的maven私服仓库</name><url>http://192.168.198.128:8081/repository/maven-public/</url></mirror></mirrors>
私服访问地址从下图获取:http://192.168.198.128:8081/#browse/browse:maven-public
项目中配置发布管理
在项目的pom.xml文件中添加<distributionManagement>
<dependencyManagement><dependencies><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${project.druid.version}</version></dependency></dependencies></dependencyManagement><distributionManagement><snapshotRepository><id>wnhz-snapshots</id><url>http://192.168.198.128:8081/repository/wnhz-snapshots/</url></snapshotRepository><repository><id>wnhz-releases</id><url>http://192.168.198.128:8081/repository/wnhz-releases/</url></repository></distributionManagement><repositories><repository><id>nexus</id><url>http://192.168.198.128/repository/wnhz-repository/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories>
部署项目
在maven中运行部署,部署(deploy)项目到私服。
项目中maven配置
<parenta>
继承父项目模块
<parent><artifactId>wnhz-bm</artifactId><groupId>com.wnhz.bm</groupId><version>1.0-SNAPSHOT</version>
</parent>
当前模块坐标
<modelVersion>4.0.0</modelVersion>
<groupId>com.wnhz.bm.common</groupId>
<artifactId>bm-common</artifactId>
<packaging>pom</packaging>
packaging配置
序列 | 参数 | 解释 |
---|---|---|
1 | pom | 表示父类型 |
2 | jar | 打包为jar包 |
3 | war | 打包为war包 |
module
配置项目的子模块名称
<modules><module>bm-common</module><module>bm-domain</module><module>bm-book</module>
</modules>
properties
定义依赖的版本号
<properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><druid.version>1.2.18</druid.version>
</properties><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${druid.version}</version>
</dependency>
dependencies
引入依赖
<dependencies><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${druid.version}</version></dependency>
</dependencies>
build
构建项目模块
插件
编译插件
<!-- 编译源代码插件 -->
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version><configuration><source>1.8</source><target>1.8</target><encoding>${project.build.sourceEncoding}</encoding></configuration>
</plugin>
打包源码插件
<build><plugins><!-- 编译源代码插件 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version><configuration><source>1.8</source><target>1.8</target><encoding>${project.build.sourceEncoding}</encoding></configuration></plugin><!-- 打包源代码插件 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>2.2.1</version><configuration><attach>true</attach></configuration><executions><execution><phase>compile</phase><goals><goal>jar</goal></goals></execution></executions></plugin></plugins></build>
springboot打包插件
打包将jar包放到项目的更目录out下。
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><outputDirectory>../../out</outputDirectory></configuration></plugin></plugins></build>
私服配置
distributionManagement
部署管理,适用于依赖上传
<snapshotRepository><id>wnhz-snapshots</id><url>http://192.168.201.81:8081/repository/wnhz-snapshots/</url></snapshotRepository><repository><id>wnhz-releases</id><url>http://192.168.201.81:8081/repository/wnhz-releases/</url></repository>
repositories
部署依赖下载
<repositories><repository><id>nexus</id><url>http://192.168.201.81:8081/repository/maven-public/</url><releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases><snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots></repository></repositories>
ory/wnhz-snapshots/
wnhz-releases
http://192.168.201.81:8081/repository/wnhz-releases/
#### repositories> 部署依赖下载```xml<repositories><repository><id>nexus</id><url>http://192.168.201.81:8081/repository/maven-public/</url><releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases><snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots></repository></repositories>
相关文章:

搭建maven私服
maven maven简介 什么是maven? Maven这个单词来自于意第绪语(犹太语),意为知识的积累。 Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的项目管理工具软件。 Maven 除了以…...

EST-100身份证社保卡签批屏按捺终端PC版web版本http协议接口文档,支持web网页开发对接使用
<!DOCTYPE html><html lang"zh-CN"><head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width,initial-scale1.0"><title>演示DEMO</title><script type"text/…...

基于SpringBoot的毕业论文管理系统
文章目录 项目介绍主要功能截图:部分代码展示设计总结项目获取方式🍅 作者主页:超级无敌暴龙战士塔塔开 🍅 简介:Java领域优质创作者🏆、 简历模板、学习资料、面试题库【关注我,都给你】 🍅文末获取源码联系🍅 项目介绍 基于SpringBoot的毕业论文管理系统,java…...

iToF人脸识别
iToF(间接飞行时间)是一种测量光飞行时间的技术,主要应用于人脸识别。 iToF人脸识别技术在哪些场景下会用到 iToF人脸识别技术可以应用于许多场景,以下是一些常见的应用场景: 平安城市:在城市监控系统中,iToF人脸识别技术可以用于实时监控、目标检测和识别,以及异常行为…...

Django开发3
Django开发3 Django开发编辑用户9.靓号管理9.1 表结构9.2 靓号列表9.3 新建靓号9.4 编辑靓号9.5 搜索手机号9.6 分页 10.时间插件11.ModelForm和BootStrap操作 各位小伙伴想要博客相关资料的话关注公众号:chuanyeTry即可领取相关资料! Django开发 部门管…...

MS2358:96KHz、24bit 音频 ADC
产品简述 MS2358 是带有采样速率 8kHz-96kHz 的立体声音频模数 转换器,适合于面向消费者的专业音频系统。 MS2358 通过使用增强型双位 Δ - ∑ 技术来实现其高精度 的特点。 MS2358 支持单端的模拟输入,所以不需要外部器 件,非常适…...

【Android12】Android Framework系列---tombstone墓碑生成机制
tombstone墓碑生成机制 Android中程序在运行时会遇到各种各样的问题,相应的就会产生各种异常信号,比如常见的异常信号 Singal 11:Segmentation fault表示无效的地址进行了操作,比如内存越界、空指针调用等。 Android中在进程(主要…...

中间件系列 - Redis入门到实战(原理篇)
前言 学习视频: 黑马程序员Redis入门到实战教程,深度透析redis底层原理redis分布式锁企业解决方案黑马点评实战项目 中间件系列 - Redis入门到实战 本内容仅用于个人学习笔记,如有侵扰,联系删除 学习目标 Redis数据结构Redis网…...

P2249 【深基13.例1】查找
P2249 【深基13.例1】查找 P2249 【深基13.例1】查找 题意 输入n 个不超过10的9次方的单调不减的(就是后面的数字不小于前面的数字)非负整数a1,a2,a3…然后进行 m 次询问。对于每次询问,给出一个整数q,要…...

linux常用shell脚本
查看系统当前进程连接数 netstat -an | grep ESTABLISHED | wc -l 如何在/usr目录下找出大小超过10MB的文件? find /usr -type f -size 10240k 添加一条到192.168.3.0/24的路由,网关为192.168.1.254? route add -net 192.168.3.0/24 netmask 255.2…...

Rust学习笔记005:结构体 struct
在 Rust 中,struct 是一种用于创建自定义数据类型的关键字,它允许你定义和组织数据的结构。struct 可以包含多个不同类型的字段(fields),每个字段都有一个名称和一个类型。 定义结构体 下面是一个简单的例子ÿ…...

maven中dependencyManagement标签
简介 dependencyManagement正如其名,用于项目依赖的统一管理。 在父项目中的pom.xml文件中加入dependencyManagement标签即可完成依赖版本的声明。在声明完成后,子项目(module)中引用相同的依赖时可以不指定version标签自动引入…...

SparkStreaming与Kafka整合
1.3 SparkStreaming与Kafka整合 1.3.1 整合简述 kafka是做消息的缓存,数据和业务隔离操作的消息队列,而sparkstreaming是一款准实时流式计算框架,所以二者的整合,是大势所趋。 二者的整合,有主要的两大版本。 kaf…...

openwrt源码编译
下载openwrt源码 git clone https://github.com/openwrt/chaos_calmer.git // 官方下载地址 当前我们基于15.05版本开发,如果开发者想用最新的OpenWRT系统,可以下载 https://github.com/openwrt/openwrt.git git clone https://github.com/Ying-Yun/o…...

【Leetcode Sheet】Weekly Practice 22
Leetcode Test 1349 参加考试的最大学生数(12.26) 给你一个 m * n 的矩阵 seats 表示教室中的座位分布。如果座位是坏的(不可用),就用 # 表示;否则,用 . 表示。 学生可以看到左侧、右侧、左上、右上这四个方向上紧邻…...

ROS TF坐标变换 - 静态坐标变换
目录 一、静态坐标变换(C实现)二、静态坐标变换(Python实现) 如前文所属,ROS通过广播的形式告知各模块的位姿关系,接下来详述这一机制的代码实现。 模块间的位置关系有两种类型,一种是相对固定…...

香橙派5plus从ssd启动Ubuntu
官方接口图 我实际会用到的就几个接口,背面的话就一个M.2固态的位置: 其中WIFI模块的接口应该也可以插2230的固态,不过是pcie2.0的速度,背面的接口则是pcie3.0*4的速度,差距还是挺大的。 开始安装系统 准备工作 一张…...

JWT+Redis 实现接口 Token 校验
1、业务逻辑 有一些接口,需要用户登录以后才能访问,用户没有登录则无法访问。 因此,对于一些限制用户访问的接口,可以在请求头中增加一个校验参数,用于判断接口对应的用户是否登录。 而对于一些不需要登录即可访问的接…...

C语言 linux文件操作(二)
文章目录 一、获取文件长度二、追加写入三、覆盖写入四、文件创建函数creat 一、获取文件长度 通过lseek函数,除了操作定位文件指针,还可以获取到文件大小,注意这里是文件大小,单位是字节。例如在file1文件中事先写入"你好世…...

机器学习分类
1. 监督学习 监督学习指的是人们给机器一大堆标记好的数据,比如: 一大堆照片,标记出哪些是猫的照片,哪些是狗的照片 让机器自己学习归纳出算法或模型 使用该算法或模型判断出其他没有标记的照片是否是猫或狗 上述流程如下图所…...

CSS之元素转换
我想大家在写代码时有一个疑问,块级元素可以转换成其他元素吗? 让我为大家介绍一下元素转换 1.display:block(转换成块元素) display:block可以把我们的行内元素或者行内块元素转换成块元素 接下来让我为大家演示一下: <!DO…...

自激振荡电路笔记 电弧打火机
三极管相关 三极管的形象描述 二极管 简单求解(理想) 优先导通(理想) 恒压降 稳压管(二极管plus) 基础工作模块 理想稳压管的工作特性 晶体管之三极管(“两个二极管的组合” ) 电弧打火机电路 1.闭合开…...

Linux su 命令
Linux su(英文全拼:switch user)命令用于变更为其他使用者的身份,除 root 外,需要键入该使用者的密码。 使用权限:所有使用者。 语法 su [-fmp] [-c command] [-s shell] [--help] [--version] [-] [USE…...

论文阅读: AAAI 2022行人重识别方向论文-PFD_Net
本篇博客用于记录一篇行人重识别方向的论文所提出的优化方法《Pose-Guided Feature Disentangling for Occluded Person Re-identification Based on Transformer》,论文中提出的PDF_Net模型的backbone是采用《TransReID: Transformer-based Object Re-Identificati…...

蓝牙物联网灯控设计方案
蓝牙技术是当前应用最广泛的无线通信技术之一,工作在全球通用的 2.4GHZ 的ISM 频段。蓝牙的工作距离约为 100 米,具有一定的穿透性,没有方向限制。具有低成本、抗干扰能力强、传输质量高、低功耗等特点。蓝牙技术组网比较简单,无需…...

Codeforces Round 900 (Div. 3)(A-F)
比赛链接 : Dashboard - Codeforces Round 900 (Div. 3) - Codeforces A. How Much Does Daytona Cost? 题面 : 思路 : 在序列中只要找到k,就返回true ; 代码 : #include<bits/stdc.h> #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)…...

vue大屏-列表自动滚动vue-seamless-scroll
vue大屏-列表自动滚动vue-seamless-scroll vue-seamless-scroll的官方文档地址:https://chenxuan0000.github.io/vue-seamless-scroll/zh/guide/ 具体效果可到官方文档那里查看。 1、下载依赖 npm install vue-seamless-scroll --save2、使用例子 <template…...

easyx的窗口函数
文章目录 前言一、EasyX的颜色二、EasyX的坐标和设备1,EasyX的坐标2,EasyX的设备 三、窗口函数1,初始化窗口函数2,关闭绘图窗口3,设置窗口背景板颜色4,清空绘图设备 前言 easyx是针对c的图形库,…...

【记录】开始学习网络安全
本文持续更新学习进度 背景 在私企干了5年虚拟化、云原生相关的运维,学到了很多,但不成体系。老板是清华毕业法国留学在德勤干过,最后回国创业的野路子。我工作是为了更好的生活,我挺担心老板因为家庭变故或者炒个原油宝&#x…...

【Java EE初阶三 】线程的状态与安全(下)
3. 线程安全 线程安全:某个代码,不管它是单个线程执行,还是多个线程执行,都不会产生bug,这个情况就成为“线程安全”。 线程不安全:某个代码,它单个线程执行,不会产生bug,…...