Java列表转树形结构工具

news2024/7/7 17:23:54

不废话,直接上代码

一、工具函数

可以直接使用list2tree()实现列表转树形结构

package com.server.utils.tree;

import org.springframework.beans.BeanUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;

/**
 * @author visy.wang
 * @date 2024/6/27 21:27
 */
public class TreeUtil {
	//通过Map的方式组装树形结构(只需单次遍历即可完成)
    public static <T,K,R> R list2tree(List<T> list,
                       				  K rootId,
                       				  Function<T,K> idGetter,
                       				  Function<T,K> pidGetter,
                       				  Function<T,R> converter,
                       				  Supplier<R> builder,
                       				  BiConsumer<R,R> childAdder){
        Map<K, R> map = new HashMap<>();
        for (T t : list) {
            K id = idGetter.apply(t), pid = pidGetter.apply(t);

            //查找当前节点
            R node = map.get(id);
            if(node == null){//当前节点不存在则创建
                node = converter.apply(t);
                map.put(id, node);
            }else{//当前节点已存在(被其他节点以父节点加入),补全剩余字段
            	R srcNode = converter.apply(t);
                BeanUtils.copyProperties(srcNode, node, getNullProperties(srcNode));
            }

            //查找父节点
            R parent = map.get(pid);
            if(parent == null){//父节点不存在,则创建父节点,并将自身添加到父节点的子节点集合中
                parent = builder.get();
                childAdder.accept(parent, node);
                map.put(pid, parent);
            }else{//父节点已存在,直接将自身添加到父节点的子节点集合中
                childAdder.accept(parent, node);
            }
        }
        return map.get(rootId);
    }

	//通过递归的方式组装树形结构(层级过多时占用内存较大,数据不规范时有内存溢出风险)
	public static <T,K,R> List<R> list2tree(List<T> list,
                                            K rootId,
                                            Function<T,K> idGetter,
                                            Function<T,K> pidGetter,
                                            Function<T,R> converter,
                                            BiConsumer<R,List<R>> childrenSetter){
        return list.stream().filter(t -> {
            K parentId = pidGetter.apply(t);
            return Objects.equals(parentId, rootId);
        }).map(t -> {
            K id = idGetter.apply(t);
            R node = converter.apply(t);
            List<R> children = list2tree(list, id, idGetter, pidGetter, converter, childrenSetter);
            if(!children.isEmpty()){
                childrenSetter.accept(node, children);
            }
            return node;
        }).collect(Collectors.toList());
    }
	
	//通过Map+实现接口的方式组装树形结构
    public static <T,K> List<TreeNode<K>> list2tree(List<T> list,
                                              		K rootId,
                                              		Function<T,TreeNode<K>> converter,
                                              		Supplier<TreeNode<K>> builder){
        Map<K, TreeNode<K>> map = new HashMap<>();
        for (T t : list) {
            TreeNode<K> node = converter.apply(t);
            K id = node.getId(), parentId = node.getParentId();

            //查找当前节点
            TreeNode<K> currNode = map.get(id);
            if(currNode != null){//当前节点已存在(被其他节点以父节点加入)
                //复制子节点集合
                node.setChildren(currNode.getChildren());
            }
            map.put(id, node);//更新或添加当前节点

            //查找父节点
            TreeNode<K> parentNode = map.get(parentId);
            if(parentNode == null){//父节点不存在,则创建父节点,并将自身添加到父节点的子节点集合中
                parentNode = builder.get();
                parentNode.addChild(node);
                map.put(parentId, parentNode);
            }else{//父节点已存在,直接将自身添加到父节点的子节点集合中
                parentNode.addChild(node);
            }
        }
        TreeNode<K> rootNode = map.get(rootId);
        return rootNode==null ? Collections.emptyList() : rootNode.getChildren();
    }

    //通过递归+实现接口的方式组装树形结构
    public static <T,K> List<TreeNode<K>> list2tree(List<T> list,
                                                    K rootId,
                                                    Function<T,TreeNode<K>> converter){
        return list.stream().map(converter).filter(node -> {
            K parentId = node.getParentId();
            return Objects.equals(parentId, rootId);
        }).peek(node -> {
            K id = node.getId();
            List<TreeNode<K>> children = list2tree(list, id, converter);
            if(!children.isEmpty()){
                node.setChildren(children);
            }
        }).collect(Collectors.toList());
    }

	private static final Map<String,Field[]> fieldsCache = new HashMap<>();
    private static String[] getNullProperties(Object obj) {
        Class<?> clazz = obj.getClass();
        String className = clazz.getName();
        Field[] fields = fieldsCache.get(className);
        if(fields == null){
            fields = clazz.getDeclaredFields();
            Field.setAccessible(fields, true);
            fieldsCache.put(className, fields);
        }

        List<String> nullProperties = new ArrayList<>();
        for (Field field : fields) {
            try {
                Object value = field.get(obj);
                if (value == null) {
                    nullProperties.add(field.getName());
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        String[] result = new String[nullProperties.size()];
        return nullProperties.toArray(result);
    }
}
二、接口定义

定义节点规范

package com.server.utils.tree;

import java.util.List;

/**
 * @author visy.wang
 * @date 2024/7/1 10:45
 */
public interface TreeNode<K> {
    K getId();

    K getParentId();

    void addChild(TreeNode<K> child);

    List<TreeNode<K>> getChildren();

    void setChildren(List<TreeNode<K>> children);
}
三、原始对象
package com.server.utils.tree;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 菜单
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Menu implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 菜单id
     */
    private Long id;

    /**
     * 父id
     */
    private Long fid;

    /**
     * 机构名称
     */
    private String name;

    /**
     * 模块id
     */
    private Integer level;


    /**
     * 状态   1 启用 2 停用
     */
    private Integer status;

    /**
     * 权重
     */
    private Integer weight;
}
四、节点对象
package com.server.utils.tree;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author visy.wang
 * @date 2024/6/27 21:54
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MenuNode extends Menu { //不一定要继承原始对象(字段都能复用的时候才考虑继承)
    /**
     * 是否勾选
     */
    private Integer isCheck;
    /**
     * 子菜单列表
     */
    private List<MenuNode> children;

    public void addChild(MenuNode child){
        if(children == null){
            children = new ArrayList<>();
        }
        children.add(child);
    }
}
五、测试
package com.server.utils.tree;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author visy.wang
 * @date 2024/6/27 21:55
 */
public class Test {
    public static void main(String[] args) {
        List<Menu> menuList = new ArrayList<>();
        //顺序可以任意调整,不影响结果
        menuList.add(new Menu(1L, null, "菜单A", 1, 1,1));
        menuList.add(new Menu(4L, 2L, "菜单BA", 2, 1,4));
        menuList.add(new Menu(3L, 1L, "菜单AA", 2, 1,3));
        menuList.add(new Menu(5L, 3L, "菜单AAA", 3, 1,5));
        menuList.add(new Menu(2L, null, "菜单B", 1, 1,2));

		//勾选的菜单ID集合
        Set<Long> checkedMenuIds = new HashSet<>();
        checkedMenuIds.add(3L);
        checkedMenuIds.add(5L);

		//map的方式
        MenuNode root = TreeUtil.list2tree(
            menuList, //原始列表
            null, //根节点ID,用于提取顶层节点
            Menu::getId, //获取ID的方法,也可以指定别的字段
            Menu::getFid, //获取父ID的方法,也可以指定别的字段,但是必须和上面的方法对应
            menu -> { //将列表中的原始对象转换成节点对象(一般来说比原始对象多了对子节点集合的持有,除此之外也可以按需要增减字段)
                MenuNode node = new MenuNode();//创建一个节点
                BeanUtils.copyProperties(menu, node);//复制原始对象的字段到节点对象
                node.setIsCheck(checkedMenuIds.contains(menu.getId()) ? 1 : 0);//单独设置其他字段
                return node;//返回节点对象
            },
            MenuNode::new, //节点对象的构造方法,用于创建一个新的父节点对象
            MenuNode::addChild //添加子节点的方法
        );

        System.out.println(JSON.toJSONString(root.getChildren()));

		//递归的方式
		List<MenuNode> menuNodeList = TreeUtil.list2tree(
            menuList, //原始列表
            null, //根节点ID
            Menu::getId, //获取ID的方法,也可以指定别的字段
            Menu::getFid, //获取父ID的方法,也可以指定别的字段,但是必须和上面的方法对应
            menu -> { //将列表中的原始对象转换成节点对象(一般来说比原始对象多了对子节点集合的持有,除此之外也可以按需要增减字段)
                MenuNode node = new MenuNode();//创建一个节点
                BeanUtils.copyProperties(menu, node);//复制原始对象的字段到节点对象
                node.setIsCheck(checkedMenuIds.contains(menu.getId()) ? 1 : 0);//单独设置其他字段
                return node;//返回节点对象
            },
            MenuNode::setChildren //设置子节点集合的方法
        );

        System.out.println(JSON.toJSONString(menuNodeList));
    }
}
六、打印结果
  • map的方式:
[
    {
        "children": [
            {
                "children": [
                    {
                        "fid": 3, 
                        "id": 5, 
                        "isCheck": 1, 
                        "level": 3, 
                        "name": "菜单AAA", 
                        "status": 1, 
                        "weight": 5
                    }
                ], 
                "fid": 1, 
                "id": 3, 
                "isCheck": 1, 
                "level": 2, 
                "name": "菜单AA", 
                "status": 1, 
                "weight": 3
            }
        ], 
        "id": 1, 
        "isCheck": 0, 
        "level": 1, 
        "name": "菜单A", 
        "status": 1, 
        "weight": 1
    }, 
    {
        "children": [
            {
                "fid": 2, 
                "id": 4, 
                "isCheck": 0, 
                "level": 2, 
                "name": "菜单BA", 
                "status": 1, 
                "weight": 4
            }
        ], 
        "id": 2, 
        "isCheck": 0, 
        "level": 1, 
        "name": "菜单B", 
        "status": 1, 
        "weight": 2
    }
]
  • 递归的方式:
[
    {
        "children": [
            {
                "children": [
                    {
                        "fid": 3, 
                        "id": 5, 
                        "isCheck": 1, 
                        "level": 3, 
                        "name": "菜单AAA", 
                        "status": 1, 
                        "weight": 5
                    }
                ], 
                "fid": 1, 
                "id": 3, 
                "isCheck": 1, 
                "level": 2, 
                "name": "菜单AA", 
                "status": 1, 
                "weight": 3
            }
        ], 
        "id": 1, 
        "isCheck": 0, 
        "level": 1, 
        "name": "菜单A", 
        "status": 1, 
        "weight": 1
    }, 
    {
        "children": [
            {
                "fid": 2, 
                "id": 4, 
                "isCheck": 0, 
                "level": 2, 
                "name": "菜单BA", 
                "status": 1, 
                "weight": 4
            }
        ], 
        "id": 2, 
        "isCheck": 0, 
        "level": 1, 
        "name": "菜单B", 
        "status": 1, 
        "weight": 2
    }
]
七、实现接口的方式
  • 节点对象

节点对象必须实现TreeNode接口,泛型中指定子父关联字段的类型

package com.server.utils.tree;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author visy.wang
 * @date 2024/7/1 11:31
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MenuNodeV2 extends Menu implements TreeNode<Long>{
    /**
     * 是否勾选
     */
    private Integer isCheck;
    /**
     * 子菜单列表
     */
    private List<TreeNode<Long>> children;

    @Override
    public Long getParentId() {
        return getFid();
    }

    @Override
    public void addChild(TreeNode<Long> child) {
        if(this.children == null){
            this.children = new ArrayList<>();
        }
        this.children.add(child);
    }
}
  • 测试
package com.server.utils.tree;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author visy.wang
 * @date 2024/6/27 21:55
 */
public class Test {
    public static void main(String[] args) {
        List<Menu> menuList = new ArrayList<>();
        //顺序可以任意调整,不影响结果
        menuList.add(new Menu(1L, null, "菜单A", 1, 1,1));
        menuList.add(new Menu(4L, 2L, "菜单BA", 2, 1,4));
        menuList.add(new Menu(3L, 1L, "菜单AA", 2, 1,3));
        menuList.add(new Menu(5L, 3L, "菜单AAA", 3, 1,5));
        menuList.add(new Menu(2L, null, "菜单B", 1, 1,2));

        //勾选的菜单ID集合
        Set<Long> checkedMenuIds = new HashSet<>();
        checkedMenuIds.add(3L);
        checkedMenuIds.add(5L);

        //map的方式+接口实现
        List<TreeNode<Long>> treeNodeList = TreeUtil.list2tree(
            menuList, //原始列表
            null, //根节点ID,用于提取顶层节点
            menu -> { //将列表中的原始对象
                MenuNodeV2 node = new MenuNodeV2();//创建一个节点
                BeanUtils.copyProperties(menu, node);//复制原始对象的字段到节点对象
                node.setIsCheck(checkedMenuIds.contains(menu.getId()) ? 1 : 0);//单独设置其他字段
                return node;//返回节点对象
            },
            MenuNodeV2::new
        );
        System.out.println(JSON.toJSONString(treeNodeList));

        //递归的方式+接口实现
        List<TreeNode<Long>> treeNodeList2 = TreeUtil.list2tree(
            menuList, //原始列表
            null, //根节点ID,用于提取顶层节点
            menu -> { //将列表中的原始对象
                MenuNodeV2 node = new MenuNodeV2();//创建一个节点
                BeanUtils.copyProperties(menu, node);//复制原始对象的字段到节点对象
                node.setIsCheck(checkedMenuIds.contains(menu.getId()) ? 1 : 0);//单独设置其他字段
                return node;//返回节点对象
            }
        );
        System.out.println(JSON.toJSONString(treeNodeList2));
    }
}
  • 打印结果

map的方式+接口实现

[
    {
        "children": [
            {
                "children": [
                    {
                        "fid": 3, 
                        "id": 5, 
                        "isCheck": 1, 
                        "level": 3, 
                        "name": "菜单AAA", 
                        "parentId": 3, 
                        "status": 1, 
                        "weight": 5
                    }
                ], 
                "fid": 1, 
                "id": 3, 
                "isCheck": 1, 
                "level": 2, 
                "name": "菜单AA", 
                "parentId": 1, 
                "status": 1, 
                "weight": 3
            }
        ], 
        "id": 1, 
        "isCheck": 0, 
        "level": 1, 
        "name": "菜单A", 
        "status": 1, 
        "weight": 1
    }, 
    {
        "children": [
            {
                "fid": 2, 
                "id": 4, 
                "isCheck": 0, 
                "level": 2, 
                "name": "菜单BA", 
                "parentId": 2, 
                "status": 1, 
                "weight": 4
            }
        ], 
        "id": 2, 
        "isCheck": 0, 
        "level": 1, 
        "name": "菜单B", 
        "status": 1, 
        "weight": 2
    }
]

递归的方式+接口实现

[
    {
        "children": [
            {
                "children": [
                    {
                        "fid": 3, 
                        "id": 5, 
                        "isCheck": 1, 
                        "level": 3, 
                        "name": "菜单AAA", 
                        "parentId": 3, 
                        "status": 1, 
                        "weight": 5
                    }
                ], 
                "fid": 1, 
                "id": 3, 
                "isCheck": 1, 
                "level": 2, 
                "name": "菜单AA", 
                "parentId": 1, 
                "status": 1, 
                "weight": 3
            }
        ], 
        "id": 1, 
        "isCheck": 0, 
        "level": 1, 
        "name": "菜单A", 
        "status": 1, 
        "weight": 1
    }, 
    {
        "children": [
            {
                "fid": 2, 
                "id": 4, 
                "isCheck": 0, 
                "level": 2, 
                "name": "菜单BA", 
                "parentId": 2, 
                "status": 1, 
                "weight": 4
            }
        ], 
        "id": 2, 
        "isCheck": 0, 
        "level": 1, 
        "name": "菜单B", 
        "status": 1, 
        "weight": 2
    }
]
八、递归方式的优化
public static <T,K,R> List<R> list2tree(List<T> list,
                                        K rootId,
                                        Function<T,K> idGetter,
                                        Function<T,K> pidGetter,
                                        Function<T,R> converter,
                                        BiConsumer<R,List<R>> childrenSetter){
    if(Objects.isNull(list) || list.isEmpty()){
        return null;
    }
    List<T> childList = new ArrayList<>(), surplusList = new ArrayList<>();
    for (T t : list) {
        if(Objects.equals(rootId, pidGetter.apply(t))){
            childList.add(t);
        }else{
            surplusList.add(t);
        }
    }
    if(childList.isEmpty()){
        return null;
    }
    return childList.stream().map(t -> {
        K id = idGetter.apply(t);
        R node = converter.apply(t);
        List<R> children = list2tree(surplusList, id, idGetter, pidGetter, converter, childrenSetter);
        childrenSetter.accept(node, children);
        return node;
    }).collect(Collectors.toList());
}
public static <T,K> List<TreeNode<K>> list2tree(List<T> list,
                                                K rootId,
                                                Function<T,TreeNode<K>> converter){
    if(Objects.isNull(list) || list.isEmpty()){
        return null;
    }
    List<T> surplusList = new ArrayList<>();//剩余列表(将已查找到的节点排除)
    List<TreeNode<K>> childList = new ArrayList<>();//rootId下的子节点列表
    for (T t : list) {
        TreeNode<K> node = converter.apply(t);
        if(Objects.equals(rootId, node.getParentId())){
            childList.add(node);
        }else{
            surplusList.add(t);
        }
    }
    childList.forEach(node -> {
        node.setChildren(list2tree(surplusList, node.getId(), converter));
    });
    return childList.isEmpty() ? null : childList;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1894462.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

自动化设备上位机设计 一

目录 一 设计原型 二 后台代码 一 设计原型 二 后台代码 namespace 自动化上位机设计 {public partial class Form1 : Form{public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){}} }namespace 自动化上位机设计 {partial class Fo…

GPU相关的一些截图(备查,待整理)

GPU相关的一些截图 这里记录一些与GPU相关的截图,方便查阅

线段树求区间最值问题

引言 今天主要还是练了两道题&#xff0c;是有关线段树如何去求一个区间内的最值问题的&#xff0c;我们可以用线段树来解决。 对应一个无法改变顺序的数组&#xff0c;我们想要去求一个区间内的最值&#xff0c;假设有n个结点&#xff0c;m次询问&#xff0c;暴力的解决办法…

【高校科研前沿】南京地理与湖泊研究所博士后夏凡为第一作者在环境科学与水资源领域Top期刊发文:钙对云南洱海溶解有机质与浮游细菌相互作用的调控作用

文章简介 论文名称&#xff1a;Calcium regulates the interactions between dissolved organic matter and planktonic bacteria in Erhai Lake, Yunnan Province, China 第一作者及单位&#xff1a;夏凡&#xff08;博士后|中国科学院南京地理与湖泊研究所&#xff09; 通讯…

关于虚拟机CentOS 7使用ssh无法连接(详细)

虚拟机CentOS 7使用ssh无法连接 猜测&#xff1a;可能是虚拟机软件的网关和和centos7的网关不同导致的问题。 首先打开CentOS7的终端, 输入ifconfig&#xff0c;查看一下系统的ip 打开虚拟机的虚拟网络编辑器, 查看一下网关, 发现确实不一样. 这里有两种方式, 要么修改虚…

fluwx插件实现微信支付

Flutter开发使用fluwx插件实现微信支付&#xff0c;代码量不多&#xff0c;复杂的是安卓和iOS的各种配置。 在 pubspec.yaml 文件中添加fluwx依赖 fluwx: ^4.5.5 使用方法 通过fluwx注册微信Api await Fluwx().registerApi(appId: wxea7a1c53d9e5849d, universalLink: htt…

Android系统集成和使用FFmpeg

文章目录 前言FFmpeg源码下载交叉编译NDK下载x264编译源码下载编译 FFmpeg编译脚本 AOSP继承FFmpeg 前言 原生AOSP中并未继承FFmpeg&#xff0c;所以要想在android上使用&#xff0c;需要自己编译集成。 FFmpeg源码下载 git clone https://git.ffmpeg.org/ffmpeg.git目前最新…

Java [ 基础 ] Stream流 ✨

✨探索Java基础Stream流✨ 在现代Java编程中&#xff0c;Stream是一个非常强大的工具&#xff0c;它提供了一种更高效和简洁的方式来处理集合数据。在这篇博客中&#xff0c;我们将深入探讨Java中的Stream流&#xff0c;介绍它的基础知识、常见操作和一些实用示例。 什么是Str…

暗潮短视频:成都柏煜文化传媒有限公司

暗潮短视频&#xff1a;涌动的新媒体力量 在数字化时代的浪潮中&#xff0c;短视频以其独特的魅力和无限的潜力&#xff0c;迅速成为新媒体领域的一股强大力量。而在这片繁荣的短视频领域中&#xff0c;成都柏煜文化传媒有限公司“暗潮短视频”以其独特的定位和深邃的内容&…

解决mysql数据库连接报错:Authentication plugin ‘caching_sha2_password‘ cannot be loaded

解决mysql数据库连接报错&#xff1a;Authentication plugin ‘caching_sha2_password’ cannot be loaded OperationalError: (2059, “Authentication plugin ‘caching_sha2_password’ cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open sha…

虚拟机与主机的联通

本地光纤分配地址给路由器--》连结路由器是连结局域网--》由路由器分配IP地址 因此在网站上搜索的IP与本机的IP是不一样的 1.windows查看主机IP地址 在终端输入 2.linux虚拟机查看ip 3.主机是否联通虚拟机ping加ip

【AI学习】无线AI的问题和挑战

无线AI&#xff0c;即无线人工智能&#xff0c;是指内生于未来&#xff08;6G&#xff09;无线通信系统并通过无线架构、无线数据、无线算法和无线应用所呈现出来的新的人工智能技术体系。 最近一直在进行无线AI的调研&#xff0c;感觉真的是路漫漫其修远兮。业界有一些探索&a…

数学建模------Matlab数据可视化

目录 1.plot函数 &#xff08;1&#xff09;函数介绍 &#xff08;2&#xff09;参数介绍 &#xff08;3&#xff09;图形美化 &#xff08;4&#xff09;背景更改 &#xff08;5&#xff09;多组绘制 &#xff08;6&#xff09;图形叠加 &#xff08;7&#xff09;添加…

Matplotlib 简介

import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4]) plt.ylabel(some numbers) plt.show() 当使用plot只传入单个数组时&#xff0c;matplotlib会认为这是y的值&#xff0c;并自动生成长度相同&#xff0c;但是从0开始的x值&#xff0c;所以这里的x会自动生成为 [0,1,2,…

Vue.js 案例——商品管理

一.需要做出的效果图&#xff1a; 二.实现的步骤 首先&#xff0c;先建一个项目&#xff0c;命名Table&#xff0c;在Table项目中的components里新建一个MyTable.vue文件。 第二步&#xff0c;在原有的 HelloWorld.vue中写入代码。 HelloWorld.vue代码如下&#xff1a; <…

土地规划与文化遗产保护:在发展浪潮中守护历史的脉络

在这个日新月异的时代&#xff0c;城市化进程如火如荼&#xff0c;土地规划作为引导城市发展方向的关键&#xff0c;承载着平衡发展与保护的重任。在追求现代化的同时&#xff0c;保护文化遗产不仅是对过去的尊重&#xff0c;更是对未来负责。本文旨在深入探讨如何在土地规划实…

云桌面运维工程师

一 深信服驻场工程师 1 深信服AC、AF、AD、NGAF、WOC Atrust、WAF项目实施经验者优先考虑。 负责云桌面POC测试 部署和配置&#xff1a;设置云桌面基础设施&#xff0c;包括虚拟化平台、云桌面管理软件和相关组件。确保正确配置网络、存储和安全设置。 用户体验&#xff1…

7.3数据库第一次作业

安装MySQL 1.打开安装包 2.选择自定义安装&#xff08;custom&#xff09;并点击下一步 3.自定义安装路径 4.点击执行 5.执行成功 6.默认选项点击下一步 7.选择新的授权方式并点击下一步 8.配置密码 9.默认配置并点击下一步 10.点击执行&#xff08;Execute&#xff09; 11.执…

bcc python开发示例

文章目录 1. hello_world.py2. hello_fields.py3. sync_timing.py4. disksnoop.py5. hello_perf_output.py6. bitehist.py7. vfsreadlat.py8. urandomread.py9. strlen_count.py10. nodejs_http_server.py11. task_switch.c12. 监视 do_execve 1. hello_world.py from bcc imp…

Ubuntu 24.04-自动安装-Nvidia驱动

教程 但在安全启动模式下可能会报错。 先在Nvidia官网找到GPU对应的驱动版&#xff0c; 1. 在软件与更新中选择合适的驱动 2. ubuntu自动安装驱动 sudo ubuntu-drivers autoinstall显示驱动 ubuntu-drivers devices3. 安装你想要的驱动 sudo apt install nvidia-driver-ve…