当前位置: 首页 > news >正文

精通Maven的捷径:一文包揽所有必知必学

Maven是每个Java程序都会遇到的包管理工具,今天整理一下Maven的相关知识,从青铜到王者,一文全了解,我们开始吧!

1、maven是什么,为什么存在?项目结构是什么样子,怎么定位jar

官方网站说了好多,整得多复杂一样,简单说:maven是一个管理包的工具。

Maven 存在的必要性是什么呐?想想开源的jar包如此之多,版本又如此之多,在没有Maven之前,我们管理jar包全部都是下载之后创建一个lib的文件夹,然后项目进行引用,在其他的项目成员需要修改一个jar的时候需要到处拷贝,在部署的时候也很麻烦,问题存在就要解决,因此出现了Maven,统一管理,统一的仓库,只需要配置是要哪个版本的包,直接下载就够了,不用拷贝,是不是很方便。

现在大的问题解决了,怎么定位一个jar包呐?

e965501434c752830e0744314044aaed.jpeg

2、Idea 的操作

1.新建maven项目

File ->新建->project

405aa04eee2fd7d5894a9dafcd2ade8e.jpeg

勾选从原型(模板)创建,选择maven-archetype-qiuckstart

943741b7389ca6fbcb211ff839071d81.jpeg

填入项目的名字,和groupId (公司域名反过来,如com.alibaba)

6f9ddf4ab9016241cbab770d810eb7c2.jpeg

选择本地仓库的位置,和自定义的setting配置

e5f2da6455cccdfd717d4b015f904798.jpeg

一路finish,然后等待idea 创建模板项目就好了。

2.配置仓库

Maven 仓库有三种类型:

  • 本地(local)
  • 中央(central)
  • 远程(remote)

当我们执行 Maven 构建命令时,Maven 开始按照以下顺序查找依赖的库:

  • 步骤 1 - 在本地仓库中搜索,如果找不到,执行步骤 2,如果找到了则执行其他操作。
  • 步骤 2 - 在中央仓库中搜索,如果找不到,并且有一个或多个远程仓库已经设置,则执行步骤 4,如果找到了则下载到本地仓库中以备将来引用。
  • 步骤 3 - 如果远程仓库没有被设置,Maven 将简单的停滞处理并抛出错误(无法找到依赖的文件)。
  • 步骤 4 - 在一个或多个远程仓库中搜索依赖的文件,如果找到则下载到本地仓库以备将来引用,否则 Maven 将停止处理并抛出错误(无法找到依赖的文件)。

阿里云仓库配置:

&nbsp;<repositories>&nbsp; &nbsp; &nbsp; &nbsp;<repository>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<id>central</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<name>aliyun maven</name>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<url>https://maven.aliyun.com/repository/public/</url>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<layout>default</layout>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!-- 是否开启发布版构件下载 -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<releases>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<enabled>true</enabled>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</releases>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!-- 是否开启快照版构件下载 -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<snapshots>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<enabled>false</enabled>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</snapshots>&nbsp; &nbsp; &nbsp; &nbsp;</repository>&nbsp; &nbsp;</repositories>

3.添加依赖,添加fastjson的依赖

举个例子:

&nbsp;<dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<groupId>com.alibaba</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<artifactId>fastjson</artifactId>&nbsp; &nbsp; &nbsp; &nbsp;</dependency>

4.打包项目

44f7ebcad864a1a2d0c140d2a209b169.jpeg

4、Maven坐标主要组成

groupId:组织标识(包名),一般常用公司域名的反序,比如com.alibaba

artifactId:项目名称,项目的具体名称

version:项目的当前版本 ,一般版本号为 大版本.小版本.小版本序号

packaging:项目的打包方式,最为常见的jar和war两种

5、maven生命周期

5.1 名词解释

lifecycle:生命周期,这是maven最高级别的的控制单元,它是一系列的phase组成,也就是说,一个生命周期,就是一个大任务的总称,不管它里面分成多少个子任务,反正就是运行一个lifecycle,就是交待了一个任务,运行完后,就得到了一个结果,中间的过程,是phase完成的,自己可以定义自己的lifecycle,包含自己想要的phase

phase:可以理解为任务单元,lifecycle是总任务,phase就是总任务分出来的一个个子任务,但是这些子任务是被规格化的,它可以同时被多个lifecycle所包含,一个lifecycle可以包含任意个phase,phase的执行是按顺序的,一个phase可以绑定很多个goal,至少为一个,没有goal的phase是没有意义的

goal: 这是执行任务的最小单元,它可以绑定到任意个phase中,一个phase有一个或多个goal,goal也是按顺序执行的,一个phase被执行时,绑定到phase里的goal会按绑定的时间被顺序执行,不管phase已经绑定了多少个goal,你自己定义的goal都可以继续绑到phase中

mojo: lifecycle与phase与goal都是概念上的东西,mojo才是做具体事情的,可以简单理解mojo为goal的实现类,它继承于AbstractMojo,有一个execute方法,goal等的定义都是通过在mojo里定义一些注释的anotation来实现的,maven会在打包时,自动根据这些anotation生成一些xml文件,放在plugin的jar包里

可以通俗理解为lifecyle 是一个公司,phrase 是具体的部门,goal 是一个项目,Mojo 是项目内部的人,其他的都是管理层级,具体的执行还是人。

5.2 生命周期

ffa1c26ab876d481bfc0703b49c365d0.jpeg

5.3 goal 的概念

一个goal是独立的,它可以被绑定到多个phase中去,也可以一个phase都没有。如果一个goal没有被绑定到任何一个lifecycle,它仍然可以直接被调用,而不是被lifecycle调用。

因此可以这样理解phase与goal的关系:

  1. phase其实就是goal的容器。实际被执行的都是goal。phase被执行时,实际执行的都是被绑定到该phase的goal。
  2. goal与goal之间是独立的。因此单独执行一个goal不会导致其他goal被执行。

goal可以通俗理解为一个项目。

5.4 生命周期和phase的关系

 clean生命周期每套生命周期都由一组阶段(Phase)组成,我们平时在命令行输入的命令总会对应于一个特定的阶段。比如,运行mvn clean ,这个的clean是Clean生命周期的一个阶段。有Clean生命周期,也有clean阶段。Clean生命周期一共包含了三个阶段:

  1. pre-clean 执行一些需要在clean之前完成的工作
  2. clean 移除所有上一次构建生成的文件
  3. post-clean 执行一些需要在clean之后立刻完成的工作

  "mvn clean" 中的clean就是上面的clean,在一个生命周期中,运行某个阶段的时候,它之前的所有阶段都会被运行,也就是说,"mvn clean"等同于 mvn pre-clean clean ,如果我们运行 mvn post-clean ,那么 pre-clean,clean 都会被运行。这是Maven很重要的一个规则,可以大大简化命令行的输入

执行phase实际执行的是goal。如果一个phase没有绑定goal,那这个phase就不会被执行。

<plugin>&nbsp;&nbsp;<groupId>com.mycompany.example</groupId>&nbsp;&nbsp;<artifactId>display-maven-plugin</artifactId>&nbsp;&nbsp;<version>1.0</version>&nbsp;&nbsp;<executions>&nbsp; &nbsp;&nbsp;<execution>&nbsp; &nbsp; &nbsp;&nbsp;<phase>process-test-resources</phase>&nbsp; &nbsp; &nbsp;&nbsp;<goals>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<goal>time</goal>&nbsp; &nbsp; &nbsp;&nbsp;</goals>&nbsp; &nbsp;&nbsp;</execution>&nbsp;&nbsp;</executions></plugin>

一个生命周期包含一些列的步骤,当执行生命周期的时候,会把所有的步骤执行一次

官方文档:

http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

http://maven.apache.org/ref/3.3.9/maven-core/lifecycles.html

6、idea maven的配置

POM 中可以指定以下配置:

  • 项目依赖 dependencies
  • 插件 plugins
  • 执行目标
  • 项目构建 profile
  • 项目版本
  • 项目开发者列表
  • 相关邮件列表信息
  • 具体的配置可以参考fastjson 的配置:

https://github.com/alibaba/fastjson/blob/master/pom.xml

7、POM有2个很重要的关系:聚合、继承

一、聚合

  如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合

1.聚合配置代码

<modules>&nbsp; &nbsp; &nbsp;&nbsp;<module>模块一</module>&nbsp; &nbsp; &nbsp;&nbsp;<module>模块二</module>&nbsp; &nbsp; &nbsp;&nbsp;<module>模块三</module></modules>

例如:对项目的Hello、HelloFriend、MakeFriends这三个模块进行聚合

<modules>&nbsp; &nbsp; &nbsp;&nbsp;<module>../Hello</module>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;<module>../HelloFriend</module>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;<module>../MakeFriends</module></modules>

 其中module的路径为相对路径。

二、继承

  继承为了消除重复的配置,我们把很多相同的配置提取出来,例如:grouptId,version,相同的依赖包等。

继承配置代码:

<parent>&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<groupId>me.gacl.maven</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<artifactId>ParentProject</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<version>0.0.1-SNAPSHOT</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<relativePath>../ParentProject/pom.xml</relativePath>&nbsp;&nbsp;</parent>

Idea 中可以新建一个maven项目,然后删光文件夹,只留一个pom.xml,然后添加模块,选择继承。

1c0181facc822e5312d4bf1aa53142c3.jpeg

8、Maven 中的 profile

Maven 中有一个概念叫做:profile,它主要是为了解决不同环境所需的不同变量、配置等问题。比如我们内网开发的数据库配置,端口配置等是和生产环境不同的,这个时候就需要区分。

有了 profile,可以根据激活的条件,启动不同条件下的配置信息。

profile 是可以有多个的,也可以同时激活多个 profile,方便自由组合。

<profiles>&nbsp; &nbsp; &nbsp; &nbsp;<profile>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--不同环境Profile的唯一id-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--开发环境-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<id>dev</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<properties>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--profiles.active是自定义的字段(名字随便起),自定义字段可以有多个-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<profiles.active>dev</profiles.active>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</properties>&nbsp; &nbsp; &nbsp; &nbsp;</profile>&nbsp; &nbsp; &nbsp; &nbsp;<profile>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--线上环境-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<id>prod</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<properties>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<profiles.active>prod</profiles.active>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</properties>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<activation>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<activeByDefault>true</activeByDefault>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</activation>&nbsp; &nbsp; &nbsp; &nbsp;</profile>&nbsp; &nbsp;</profiles> c7ff93788a7b9ef48839cabd5af38ed5.jpeg

Idea 中会显示配置的两个profile ,可以选择激活

bd5adab3779605250231fdf0ac486023.jpeg

pom文件里的配置为

<build>&nbsp; &nbsp; &nbsp; &nbsp;<resources>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<resource>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<directory>src/main/resources/</directory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--先排除掉两个文件夹-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<excludes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<exclude>dev/*</exclude>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<exclude>prod/*</exclude>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</excludes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--如果有其他定义通用文件,需要包含进来-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--<include>messages/*</include>-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</resource>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<resource>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--这里是关键!根据不同的环境,把对应文件夹里的配置文件打包-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<directory>src/main/resources/${profiles.active}</directory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</resource>&nbsp; &nbsp; &nbsp; &nbsp;</resources>&nbsp; &nbsp;</build> &nbsp;&nbsp;<profiles>&nbsp; &nbsp; &nbsp; &nbsp;<profile>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--不同环境Profile的唯一id-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--开发环境-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<id>dev</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<properties>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--profiles.active是自定义的字段(名字随便起),自定义字段可以有多个-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<profiles.active>dev</profiles.active>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</properties>&nbsp; &nbsp; &nbsp; &nbsp;</profile>&nbsp; &nbsp; &nbsp; &nbsp;<profile>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<!--线上环境-->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<id>prod</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<properties>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<profiles.active>prod</profiles.active>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</properties>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<activation>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<activeByDefault>true</activeByDefault>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</activation>&nbsp; &nbsp; &nbsp; &nbsp;</profile>&nbsp; &nbsp;</profiles>

9、maven 插件

Maven的核心仅仅定义了抽象的生命周期,具体的任务都是交由插件完成的。

每个插件都能实现多个功能,每个功能就是一个插件目标goal。

Maven的生命周期与插件目标相互绑定,以完成某个具体的构建任务,例如compile就是插件maven-compiler-plugin的一个插件目标。

常用插件:

maven-antrun-plugin maven-archetype-plugin maven-assembly-plugin maven-dependency-plugin maven-enforcer-plugin maven-help-plugin maven-release-plugin maven-resources-plugin maven-surefire-plugin build-helper-maven-plugin exec-maven-plugin jetty-maven-plugin versions-maven-plugin

10、环境变量

${basedir}表示项目根目录,即包含pom.xml文件的目录;

${version}表示项目版本;

${project.basedir}同${basedir};

${project.baseUri}表示项目文件地址;

${maven.build.timestamp}表示项目构件开始时间;

${maven.build.timestamp.format}表示属性${maven.build.timestamp}的展示格式,默认值为yyyyMMdd-HHmm,可自定义其格式,其类型可参考java.text.SimpleDateFormat。

${project.build.directory}表示主源码路径;

${project.build.sourceEncoding}表示主源码的编码格式;

${project.build.sourceDirectory}表示主源码路径;

${project.build.finalName}表示输出文件名称;

${project.version}表示项目版本,与${version}相同;

${project.xxx} 当前pom文件的任意节点的内容

${env.xxx} 获取系统环境变量。

${settings.xxx} 指代了settings.xml中对应元素的值。


11、Maven 依赖冲突的2个方法

1.统一版本

使用dependencyManagement 进行版本锁定,dependencyManagement可以统一管理项目的版本号,确保应用的各个项目的依赖和版本一致。

如果我们项目中只想使用spring core 5.2.0的包,pom.xml可以改为如下

<dependencyManagement>&nbsp; &nbsp; &nbsp; &nbsp;<dependencies>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<groupId>org.springframework</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<artifactId>spring-core</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<version>5.2.0.RELEASE</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</dependency>&nbsp; &nbsp; &nbsp; &nbsp;</dependencies>&nbsp; &nbsp;</dependencyManagement> &nbsp; &nbsp;<dependencies>&nbsp; &nbsp; &nbsp; &nbsp;<dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<groupId>org.springframework</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<artifactId>spring-context</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<version>5.2.7.RELEASE</version>&nbsp; &nbsp; &nbsp; &nbsp;</dependency> &nbsp; &nbsp; &nbsp; &nbsp;<dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<groupId>org.springframework</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<artifactId>spring-aop</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<version>5.2.0.RELEASE</version>&nbsp; &nbsp; &nbsp; &nbsp;</dependency> &nbsp; &nbsp;</dependencies>

2.排除依赖

依赖查找的两个原则:

使用路径近者优先原则:直接依赖级别高于传递依赖。

使用第一声明者优先原则:谁先定义的就用谁的传递依赖,即在pom.xml文件自上而下,先声明的jar坐标,就先引用该jar的传递依赖。

Idea 可以安装maven helper插件,解决冲突。

maven helper插件安装成功,点开pom.xml会发现多了一个Dependency Analyzer视图,如下上面按钮的图标含义如下

Conflicts(查看冲突)

All Dependencies as List(列表形式查看所有依赖)

All Dependencies as Tree(树形式查看所有依赖)

上图说明有3个jar存在冲突,点击冲突的jar,可以查看和哪个jar产生冲突,如下图

9a2f3e842bc370c47cdbf85b0c13bc8f.jpeg

点开pom.xml,切换到Dependency Analyzer视图,选择All Dependencies as Tree,点击要排除的jar,右键会出现Execlude选项,如下

60b0e0703b1fc98896822b31e71f3c6c.jpeg

总结:

Maven是开发中常用的工具,很重要,所以尽可能地掌握。

你还知道Maven的哪些知识,欢迎留言交流!!!

相关文章:

精通Maven的捷径:一文包揽所有必知必学

Maven是每个Java程序都会遇到的包管理工具&#xff0c;今天整理一下Maven的相关知识&#xff0c;从青铜到王者&#xff0c;一文全了解&#xff0c;我们开始吧&#xff01; 1、maven是什么&#xff0c;为什么存在&#xff1f;项目结构是什么样子&#xff0c;怎么定位jar 官方网…...

SpringCloud溯源——从单体架构到微服务Microservices架构 分布式和微服务 为啥要用微服务

前言 单体架构好好的&#xff0c;为啥要用微服务呢&#xff1f;微服务究竟是啥&#xff0c;怎么来的&#xff0c;有啥优缺点&#xff0c;本篇博客尝试追根溯源&#xff0c;阐述单体应用到分布式&#xff0c;微服务的演变,微服务架构的定义及优缺点&#xff0c;厘清相关的概念。…...

springboot 配置 servlet filter 2

springboot 配置 servlet filter 2 以配置Druid为例 Servlet WebServlet(urlPatterns "/druid/*",initParams {WebInitParam(name "loginUsername", value "admin"),// 登录用户名WebInitParam(name "loginPassword", value …...

前端axios下载导出文件工具封装

使用示例&#xff1a; import { fileDownload } from /utils/fileDownloadfileDownload({ url: process.env.VUE_APP_BASE_URL /statistic/pageList/export, method: post, data: data })工具类&#xff1a; import store from ../store/index import {getAccessToken } fro…...

Web应用防火墙的性能优化技术

Web应用防火墙&#xff08;WAF&#xff09;是企业网络安全的重要屏障&#xff0c;其性能直接影响到网络服务的质量和安全。本文详细探讨了WAF性能优化的几种技术&#xff0c;旨在为网络安全专业人员提供实用的参考。 规则优化 1.1 精简规则集 规则评估&#xff1a;定期评估规…...

华为HCIP题库h12-821题库新增30题

901、 &#xff08;多选题&#xff09;下面关于BGP中的公认属性的描述&#xff0c;正确的是 A、公认必属性是所有BGP路由器都识别&#xff0c;且必须存在于Updata消息中 B、BGP必须识别所有公认属性 C、公认属性分为公认必遵和可选过渡两种 D、公认任意属性是所有BGP造由器…...

智慧办公数据可视化大屏设计(数据可视化)、大数据、数据大屏、办公数据大屏、办公数据

本次分享的作品是用软件Axure8.0&#xff08;兼容9和10&#xff09;制作的智慧办公数据进行的可视化大屏设计&#xff0c;主要是针对办公的综合数据、工位数据、会议室数据、访客数据、能耗数据以及设备智控数据进行可视化数据分析。 1、综合分析:对办公室的整体数据、空气质量…...

echarts实现横轴刻度名倾斜展示,并且解决文字超出部分消失问题

需求背景&#xff1a; xAxis.axisLabel. interval如果不手动设值的话&#xff0c;默认就是‘auto’&#xff0c;会采用标签不重叠的策略间隔显示标签。当数据量特别大的时候&#xff0c;展示出来的刻度标签就会很少&#xff0c;导致用户体验不好。如下图所示&#xff1a; 如果…...

awk常用统计命令

统计列的某元素个数 # 统计第4列为0的个数 awk $4 0 { count } END { print count } your_file.txt awk $4 0 { print } your_file.txt # 第4列为0的行打印到屏幕 awk $4 0 your_file.txt...

Linux:【Kafka四】集群介绍与单机搭建

目录 环境简介 一、搭建kafka集群 1.1、复制出两个kafka的配置文件 1.2、修改配置文件中的如下属性 二、启动kafka集群 三、可校验kafka三个节点是否均启动成功 四、查看集群中主题的分区和副本 4.1、新建一个包含了分区和副本的主题 4.2、查看该主题的详细信息 五、…...

代码随想录算法训练营Day52|动态规划11

代码随想录算法训练营Day52|动态规划11 文章目录 代码随想录算法训练营Day52|动态规划11一、123.买卖股票的最佳时机III二、188.买卖股票的最佳时机IV 买卖股票 难 一、123.买卖股票的最佳时机III class Solution {public int maxProfit(int[] prices) {int[] dp new int[4]…...

Android渲染系列之原理概述篇

屏幕硬件 渲染离不开屏幕&#xff0c;Android中的屏幕碎片化比较严重&#xff0c;尺寸大小不一&#xff0c;材质也是屏幕重要的因素。 目前智能手机主流的屏幕可分为两大类即液晶显示器; LCD (Liquid Crystal Display) 液晶显示器OLED (Organic Light Emitting Diode&#xf…...

类图 UML从入门到放弃系列之二

1.劝退说明(开个玩笑) UML包含有许多小组件、修饰符以及其他小巧复杂的东西。UML的内容相当庞大&#xff0c;以至于你可以花大量的时间把自己修成一个UML语言律师&#xff0c;并能够完成所有律师能够完成的工作&#xff1a;编写出所有人都无法理解的文档。现在流行的敏捷开发倡…...

诊断用抗原抗体——博迈伦

抗原抗体诊断是一种常见的临床诊断方法&#xff0c;它通过检测人体内特定抗原或抗体的存在来确定某种疾病或感染的存在与否。这种诊断方法可以用于许多不同的疾病和感染的检测&#xff0c;如传染病、自身免疫病、肿瘤等。 抗原抗体诊断的原理是基于抗原与抗体之间的特异性反应。…...

156 - Ananagrams (UVA)

题目链接如下&#xff1a; Online Judge 我的代码如下&#xff1a; #include <iostream> #include <string> #include <vector> #include <map> #include <algorithm> // #define debugint main(){#ifdef debugfreopen("0.txt", &q…...

vue3入门

一. Vue3的优势 二. 使用create-vue搭建Vue3项目 2.1 认识create-vue create-vue是Vue官方新的脚手架工具&#xff0c;底层切换到了 vite &#xff08;下一代前端工具链&#xff09;&#xff0c;为开发提供极速响应 2.2 使用create-vue创建项目 前置条件 - 已安装16.0或更高版…...

上机实验二 设计单循环链表 西安石油大学数据结构

实验名称:设计单循环链表 (1&#xff09;实验目的:掌握线性表的链式存储结构;掌握单循环链表及其基本操作的实现。 (2&#xff09;主要内容:实现单循环链表的初始化、求数据元素个数、插入、删除、取数据元素等操作;用插入法建立带头结点的单循环链表;设计一个测试主函数验证…...

小谈设计模式(28)—解释器模式

小谈设计模式&#xff08;28&#xff09;—解释器模式 专栏介绍专栏地址专栏介绍 解释器模式角色分析抽象表达式&#xff08;Abstract Expression&#xff09;终结符表达式&#xff08;Terminal Expression&#xff09;非终结符表达式&#xff08;Non-terminal Expression&…...

Access denied for user ‘root‘@‘xxx‘ (using password: YES)

Access denied for user rootxxx (using password: YES) 这表示MySQL服务端拒绝来自xxx主机的root用户登录&#xff0c;尽管我检查了一下&#xff0c;root的用户名和密码都没错&#xff0c;还是拒绝。 解决方案&#xff1a; select user,host from mysql.user; 执行发现&am…...

对象与成员函数指针 function+bind

functionbind的理解 function模板类的构造函数&#xff0c;把对象与成员函数绑定&#xff0c;重载了&#xff08;&#xff09;&#xff0c;利用对象调用成员函数 bind模板函数&#xff0c;把对象与成员函数绑定&#xff0c;返回function对象&#xff0c;成员函数传参代码链接点…...

Cursor实现用excel数据填充word模版的方法

cursor主页&#xff1a;https://www.cursor.com/ 任务目标&#xff1a;把excel格式的数据里的单元格&#xff0c;按照某一个固定模版填充到word中 文章目录 注意事项逐步生成程序1. 确定格式2. 调试程序 注意事项 直接给一个excel文件和最终呈现的word文件的示例&#xff0c;…...

C++_核心编程_多态案例二-制作饮品

#include <iostream> #include <string> using namespace std;/*制作饮品的大致流程为&#xff1a;煮水 - 冲泡 - 倒入杯中 - 加入辅料 利用多态技术实现本案例&#xff0c;提供抽象制作饮品基类&#xff0c;提供子类制作咖啡和茶叶*//*基类*/ class AbstractDr…...

CVPR 2025 MIMO: 支持视觉指代和像素grounding 的医学视觉语言模型

CVPR 2025 | MIMO&#xff1a;支持视觉指代和像素对齐的医学视觉语言模型 论文信息 标题&#xff1a;MIMO: A medical vision language model with visual referring multimodal input and pixel grounding multimodal output作者&#xff1a;Yanyuan Chen, Dexuan Xu, Yu Hu…...

进程地址空间(比特课总结)

一、进程地址空间 1. 环境变量 1 &#xff09;⽤户级环境变量与系统级环境变量 全局属性&#xff1a;环境变量具有全局属性&#xff0c;会被⼦进程继承。例如当bash启动⼦进程时&#xff0c;环 境变量会⾃动传递给⼦进程。 本地变量限制&#xff1a;本地变量只在当前进程(ba…...

rknn优化教程(二)

文章目录 1. 前述2. 三方库的封装2.1 xrepo中的库2.2 xrepo之外的库2.2.1 opencv2.2.2 rknnrt2.2.3 spdlog 3. rknn_engine库 1. 前述 OK&#xff0c;开始写第二篇的内容了。这篇博客主要能写一下&#xff1a; 如何给一些三方库按照xmake方式进行封装&#xff0c;供调用如何按…...

【Oracle APEX开发小技巧12】

有如下需求&#xff1a; 有一个问题反馈页面&#xff0c;要实现在apex页面展示能直观看到反馈时间超过7天未处理的数据&#xff0c;方便管理员及时处理反馈。 我的方法&#xff1a;直接将逻辑写在SQL中&#xff0c;这样可以直接在页面展示 完整代码&#xff1a; SELECTSF.FE…...

为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?

在建筑行业&#xff0c;项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升&#xff0c;传统的管理模式已经难以满足现代工程的需求。过去&#xff0c;许多企业依赖手工记录、口头沟通和分散的信息管理&#xff0c;导致效率低下、成本失控、风险频发。例如&#…...

定时器任务——若依源码分析

分析util包下面的工具类schedule utils&#xff1a; ScheduleUtils 是若依中用于与 Quartz 框架交互的工具类&#xff0c;封装了定时任务的 创建、更新、暂停、删除等核心逻辑。 createScheduleJob createScheduleJob 用于将任务注册到 Quartz&#xff0c;先构建任务的 JobD…...

vue3 定时器-定义全局方法 vue+ts

1.创建ts文件 路径&#xff1a;src/utils/timer.ts 完整代码&#xff1a; import { onUnmounted } from vuetype TimerCallback (...args: any[]) > voidexport function useGlobalTimer() {const timers: Map<number, NodeJS.Timeout> new Map()// 创建定时器con…...

【git】把本地更改提交远程新分支feature_g

创建并切换新分支 git checkout -b feature_g 添加并提交更改 git add . git commit -m “实现图片上传功能” 推送到远程 git push -u origin feature_g...