首页 > 其他分享 >SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据

SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据

时间:2023-08-21 10:31:36浏览次数:45  
标签:box index SpringBoot int data 1692583966621 线程 ThreadPoolTaskExecutor

微信公众号访问地址:SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据

一、背景:

    利用ThreadPoolTaskExecutor多线程异步批量插入,提高百万级数据插入效率。ThreadPoolTaskExecutor是对ThreadPoolExecutor进行了封装处理。ThreadPoolTaskExecutor是ThreadPoolExecutor的封装,所以,性能更加优秀,推荐ThreadPoolTaskExecutor。

SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据_线程池

二、具体细节:

SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据_java_02

2.1、配置application.yml

# 异步线程配置 自定义使用参数
async:
  executor:
    thread:
      core_pool_size:  10  # 配置核心线程数 默认8个 核数*2+2
      max_pool_size:  100   # 配置最大线程数
      queue_capacity:  99988  # 配置队列大小
      keep_alive_seconds:  20  #设置线程空闲等待时间秒s
      name:
        prefix: async-thread-  # 配置线程池中的线程的名称前缀

2.2、ThreadPoolConfig配置注入Bean

package com.wonders.common.config;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;


/**
 * @Description: TODO:利用ThreadPoolTaskExecutor多线程批量执行相关配置
 * 自定义线程池
 * 发现不是线程数越多越好,具体多少合适,网上有一个不成文的算法:CPU核心数量*2 +2 个线程。
 * @Author: yyalin
 * @CreateDate: 2022/11/6 11:56
 * @Version: V1.0
 */
@Configuration
@EnableAsync
@Slf4j
public class ThreadPoolConfig {
    //自定义使用参数
    @Value("${async.executor.thread.core_pool_size}")
    private int corePoolSize;   //配置核心线程数
    @Value("${async.executor.thread.max_pool_size}")
    private int maxPoolSize;    //配置最大线程数
    @Value("${async.executor.thread.queue_capacity}")
    private int queueCapacity;
    @Value("${async.executor.thread.name.prefix}")
    private String namePrefix;
    @Value("${async.executor.thread.keep_alive_seconds}")
    private int keepAliveSeconds;


    //1、自定义asyncServiceExecutor线程池
    @Bean(name = "asyncServiceExecutor")
    public ThreadPoolTaskExecutor asyncServiceExecutor() {
        log.info("start asyncServiceExecutor......");
        //在这里修改
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        //配置核心线程数
        executor.setCorePoolSize(corePoolSize);
        //配置最大线程数
        executor.setMaxPoolSize(maxPoolSize);
        //设置线程空闲等待时间 s
        executor.setKeepAliveSeconds(keepAliveSeconds);
        //配置队列大小 设置任务等待队列的大小
        executor.setQueueCapacity(queueCapacity);
        //配置线程池中的线程的名称前缀
        //设置线程池内线程名称的前缀-------阿里编码规约推荐--方便出错后进行调试
        executor.setThreadNamePrefix(namePrefix);
        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
        //执行初始化
        executor.initialize();
        return executor;
    }
    /**
     * 2、公共线程池,利用系统availableProcessors线程数量进行计算
     */
    @Bean(name = "commonThreadPoolTaskExecutor")
    public ThreadPoolTaskExecutor commonThreadPoolTaskExecutor() {
        ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
        int processNum = Runtime.getRuntime().availableProcessors(); // 返回可用处理器的Java虚拟机的数量
        int corePoolSize = (int) (processNum / (1 - 0.2));
        int maxPoolSize = (int) (processNum / (1 - 0.5));
        pool.setCorePoolSize(corePoolSize); // 核心池大小
        pool.setMaxPoolSize(maxPoolSize); // 最大线程数
        pool.setQueueCapacity(maxPoolSize * 1000); // 队列程度
        pool.setThreadPriority(Thread.MAX_PRIORITY);
        pool.setDaemon(false);
        pool.setKeepAliveSeconds(300);// 线程空闲时间
        return pool;
    }
   //3自定义defaultThreadPoolExecutor线程池
    @Bean(name = "defaultThreadPoolExecutor", destroyMethod = "shutdown")
    public ThreadPoolExecutor systemCheckPoolExecutorService() {
        int maxNumPool=Runtime.getRuntime().availableProcessors();
        return new ThreadPoolExecutor(3,
                maxNumPool,
                60,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable" data-textnode-index-1692583966621="268" data-index-1692583966621="3909" data-index-len-1692583966621="3909" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>(10000),
                //置线程名前缀,例如设置前缀为hutool-thread-,则线程名为hutool-thread-1之类。
                new ThreadFactoryBuilder().setNamePrefix("default-executor-thread-%d").build(),
                (r, executor) -" data-textnode-index-1692583966621="276" data-index-1692583966621="4114" data-index-len-1692583966621="4114" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> log.error("system pool is full! "));
    }


}

2.3、创建异步线程,业务类

//1、自定义asyncServiceExecutor线程池
    @Override
    @Async("asyncServiceExecutor")
    public void executeAsync(List<Student" data-textnode-index-1692583966621="297" data-index-1692583966621="4291" data-index-len-1692583966621="4291" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> students,
                             StudentService studentService,
                             CountDownLatch countDownLatch) {
        try{
            log.info("start executeAsync");
            //异步线程要做的事情
            studentService.saveBatch(students);
            log.info("end executeAsync");
        }finally {
            countDownLatch.countDown();// 很关键, 无论上面程序是否异常必须执行countDown,否则await无法释放
        }
    }

2.4、拆分集合工具类

package com.wonders.threads;


import com.google.common.collect.Lists;
import org.springframework.util.CollectionUtils;


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


/**
 * @Description: TODO:拆分工具类
 * 1、获取需要进行批量更新的大集合A,对大集合进行拆分操作,分成N个小集合A-1 ~ A-N;
 * 2、开启线程池,针对集合的大小进行调参,对小集合进行批量更新操作;
 * 3、对流程进行控制,控制线程执行顺序。按照指定大小拆分集合的工具类
 * @Author: yyalin
 * @CreateDate: 2022/5/6 14:43
 * @Version: V1.0
 */
public class SplitListUtils {
    /**
     * 功能描述:拆分集合
     * @param <T" data-textnode-index-1692583966621="360" data-index-1692583966621="5164" data-index-len-1692583966621="5164" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> 泛型对象
     * @MethodName: split
     * @MethodParam: [resList:需要拆分的集合, subListLength:每个子集合的元素个数]
     * @Return: java.util.List<java.util.List<T" data-textnode-index-1692583966621="369" data-index-1692583966621="5306" data-index-len-1692583966621="5306" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>" data-textnode-index-1692583966621="369" data-index-1692583966621="5307" data-index-len-1692583966621="5307" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>:返回拆分后的各个集合组成的列表
     * 代码里面用到了guava和common的结合工具类
     * @Author: yyalin
     * @CreateDate: 2022/5/6 14:44
     */
    public static <T" data-textnode-index-1692583966621="382" data-index-1692583966621="5439" data-index-len-1692583966621="5439" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> List<List<T" data-textnode-index-1692583966621="382" data-index-1692583966621="5452" data-index-len-1692583966621="5452" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>" data-textnode-index-1692583966621="382" data-index-1692583966621="5453" data-index-len-1692583966621="5453" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> split(List<T" data-textnode-index-1692583966621="382" data-index-1692583966621="5467" data-index-len-1692583966621="5467" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> resList, int subListLength) {
        if (CollectionUtils.isEmpty(resList) || subListLength <= 0) {
            return Lists.newArrayList();
        }
        List<List<T" data-textnode-index-1692583966621="394" data-index-1692583966621="5635" data-index-len-1692583966621="5635" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>" data-textnode-index-1692583966621="394" data-index-1692583966621="5636" data-index-len-1692583966621="5636" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> ret = Lists.newArrayList();
        int size = resList.size();
        if (size <= subListLength) {
            // 数据量不足 subListLength 指定的大小
            ret.add(resList);
        } else {
            int pre = size / subListLength;
            int last = size % subListLength;
            // 前面pre个集合,每个大小都是 subListLength 个元素
            for (int i = 0; i < pre; i++) {
                List<T" data-textnode-index-1692583966621="422" data-index-1692583966621="6020" data-index-len-1692583966621="6020" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> itemList = Lists.newArrayList();
                for (int j = 0; j < subListLength; j++) {
                    itemList.add(resList.get(i * subListLength + j));
                }
                ret.add(itemList);
            }
            // last的进行处理
            if (last " data-textnode-index-1692583966621="438" data-index-1692583966621="6289" data-index-len-1692583966621="6289" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> 0) {
                List<T" data-textnode-index-1692583966621="441" data-index-1692583966621="6317" data-index-len-1692583966621="6317" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> itemList = Lists.newArrayList();
                for (int i = 0; i < last; i++) {
                    itemList.add(resList.get(pre * subListLength + i));
                }
                ret.add(itemList);
            }
        }
        return ret;
    }


    /**
     * 功能描述:方法二:集合切割类,就是把一个大集合切割成多个指定条数的小集合,方便往数据库插入数据
     * 推荐使用
     * @MethodName: pagingList
     * @MethodParam:[resList:需要拆分的集合, subListLength:每个子集合的元素个数]
     * @Return: java.util.List<java.util.List<T" data-textnode-index-1692583966621="470" data-index-1692583966621="6779" data-index-len-1692583966621="6779" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>" data-textnode-index-1692583966621="470" data-index-1692583966621="6780" data-index-len-1692583966621="6780" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>:返回拆分后的各个集合组成的列表
     * @Author: yyalin
     * @CreateDate: 2022/5/6 15:15
     */
    public static <T" data-textnode-index-1692583966621="482" data-index-1692583966621="6880" data-index-len-1692583966621="6880" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> List<List<T" data-textnode-index-1692583966621="482" data-index-1692583966621="6893" data-index-len-1692583966621="6893" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>" data-textnode-index-1692583966621="482" data-index-1692583966621="6894" data-index-len-1692583966621="6894" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> pagingList(List<T" data-textnode-index-1692583966621="482" data-index-1692583966621="6913" data-index-len-1692583966621="6913" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> resList, int pageSize){
        //判断是否为空
        if (CollectionUtils.isEmpty(resList) || pageSize <= 0) {
            return Lists.newArrayList();
        }
        int length = resList.size();
        int num = (length+pageSize-1)/pageSize;
        List<List<T" data-textnode-index-1692583966621="504" data-index-1692583966621="7169" data-index-len-1692583966621="7169" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>" data-textnode-index-1692583966621="504" data-index-1692583966621="7170" data-index-len-1692583966621="7170" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> newList =  new ArrayList<" data-textnode-index-1692583966621="506" data-index-1692583966621="7197" data-index-len-1692583966621="7197" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>();
        for(int i=0;i<num;i++){
            int fromIndex = i*pageSize;
            int toIndex = (i+1)*pageSize<length?(i+1)*pageSize:length;
            newList.add(resList.subList(fromIndex,toIndex));
        }
        return newList;
    }


    // 运行测试代码 可以按顺序拆分为11个集合
    public static void main(String[] args) {
        //初始化数据
        List<String" data-textnode-index-1692583966621="545" data-index-1692583966621="7543" data-index-len-1692583966621="7543" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> list = Lists.newArrayList();
        int size = 19;
        for (int i = 0; i < size; i++) {
            list.add("hello-" + i);
        }
        // 大集合里面包含多个小集合
        List<List<String" data-textnode-index-1692583966621="564" data-index-1692583966621="7726" data-index-len-1692583966621="7726" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>" data-textnode-index-1692583966621="564" data-index-1692583966621="7727" data-index-len-1692583966621="7727" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> temps = pagingList(list, 100);
        int j = 0;
        // 对大集合里面的每一个小集合进行操作
        for (List<String" data-textnode-index-1692583966621="576" data-index-1692583966621="7829" data-index-len-1692583966621="7829" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> obj : temps) {
            System.out.println(String.format("row:%s -" data-textnode-index-1692583966621="578" data-index-1692583966621="7899" data-index-len-1692583966621="7899" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> size:%s,data:%s", ++j, obj.size(), obj));
        }
    }


}

2.5、造数据,多线程异步插入

public int batchInsertWay() throws Exception {
        log.info("开始批量操作.........");
        Random rand = new Random();
        List<Student" data-textnode-index-1692583966621="601" data-index-1692583966621="8110" data-index-len-1692583966621="8110" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> list = new ArrayList<" data-textnode-index-1692583966621="605" data-index-1692583966621="8133" data-index-len-1692583966621="8133" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>();
        //造100万条数据
        for (int i = 0; i < 1000003; i++) {
            Student student=new Student();
            student.setStudentName("大明:"+i);
            student.setAddr("上海:"+rand.nextInt(9) * 1000);
            student.setAge(rand.nextInt(1000));
            student.setPhone("134"+rand.nextInt(9) * 1000);
            list.add(student);
        }
        //2、开始多线程异步批量导入
        long startTime = System.currentTimeMillis(); // 开始时间
        //boolean a=studentService.batchInsert(list);
        List<List<Student" data-textnode-index-1692583966621="652" data-index-1692583966621="8648" data-index-len-1692583966621="8648" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">>" data-textnode-index-1692583966621="652" data-index-1692583966621="8649" data-index-len-1692583966621="8649" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> list1=SplitListUtils.pagingList(list,100);  //拆分集合
        CountDownLatch countDownLatch = new CountDownLatch(list1.size());
        for (List<Student" data-textnode-index-1692583966621="663" data-index-1692583966621="8799" data-index-len-1692583966621="8799" class="character" style="margin: 0px; padding: 0px; box-sizing: border-box; max-width: 100%; display: inline-block; text-indent: initial;">> list2 : list1) {
            asyncService.executeAsync(list2,studentService,countDownLatch);
        }
        try {
            countDownLatch.await(); //保证之前的所有的线程都执行完成,才会走下面的;
            long endTime = System.currentTimeMillis(); //结束时间
            log.info("一共耗时time: " + (endTime - startTime) / 1000 + " s");
            // 这样就可以在下面拿到所有线程执行完的集合结果
        } catch (Exception e) {
            log.error("阻塞异常:"+e.getMessage());
        }
        return list.size();


    }

2.6、测试结果

SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据_SpringBoot_03

10个核心线程:

SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据_java_04

20个核心线程

SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据_SpringBoot_05

50个核心线程:

SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据_java_06

汇总结果:

序号

核心线程(core_pool_size)

插入数据(万)

耗时(秒)

1

10

100w

31s

2

15

100w

28s

3

50

100w

27s

结论:对不同线程数的测试,发现不是线程数越多越好,具体多少合适,网上有一个不成文的算法:CPU核心数量*2 +2 个线程。

个人推荐配置:

int processNum = Runtime.getRuntime().availableProcessors(); // 返回可用处理器的Java虚拟机的数量
int corePoolSize = (int) (processNum / (1 - 0.2));
int maxPoolSize = (int) (processNum / (1 - 0.5));

 

SpringBoot用线程池ThreadPoolTaskExecutor异步处理百万级数据_SpringBoot_07

      如果大家对相关文章感兴趣,可以关注微信公众号"程序猿小杨",会持续更新优秀文章!欢迎大家 分享、收藏、点赞、在看,您的支持就是我坚持下去的最大动力!谢谢!

标签:box,index,SpringBoot,int,data,1692583966621,线程,ThreadPoolTaskExecutor
From: https://blog.51cto.com/u_11866810/7171766

相关文章

  • SpringBoot 测试实践 - 1:常用的工具
    我自己接触到的一些商业或是开源的基于SpringBoot项目,它们大部分是没有测试代码的,test文件夹只有脚手架初始化生成的那个测试类,跟不同的开发聊到这个话题,发现他们中的大部分没有写测试的习惯,或者是觉得写测试代码麻烦,主要还是依赖测试工程师做黑盒的测试。只做黑盒测试的话有一......
  • 探索Java中的并发编程:多线程同步与性能优化
    在后端开发领域,Java作为一门强大的编程语言,广泛应用于构建高性能和并发性能强大的应用程序。本文将深入探讨Java中的并发编程,重点关注多线程同步机制与性能优化策略。通过结合实际代码示例,为读者提供关于并发编程的深奥知识和实用方法。1.并发编程概述与原理并发编程是指多个线程......
  • jmeter详解-线程组详解(6)-jp@gc - Stepping Thread Group
    jp@gc-SteppingThreadGroup线程组模拟测试场景:从某个值开始不断增加压力,直至达到某个值,然后持续运行一段时间。添加方式:页面说明:thisgroupwillstart:表示总共要启动的线程数;若设置为100,表示总共会加载到100个线程first,waitfor:从运行之后多长时间开始启动线程;若......
  • 多线程爬虫
    pythonGIL锁同步线程的一种机制,即使在多处理器也是仅有一个线程在执行避免GIL用multiprocessing替代Thread用多进程代替多线程,每个进程有自己的独立的GIL,不会出现进程之间的GIL争抢。多进程的创建和销毁开销也会更大,成本高LOCK锁原子操作 一步是计算,一步的赋值,所以不是......
  • SpringBoot - 登录
    目录会话技术登录流程:会话技术会话:用户打开浏览器,访问web服务器的资源,会话建立,直到有一方断开连接,会话结束。在一起会话中包含多次请求和响应会话跟踪:一种维护浏览器状态的方法,服务器需要识别多次请求是否来自于同一浏览器,以便在同一次会话的多次请求间共享数据会话跟踪方......
  • Springboot内嵌neo4j配置
    环境说明MacOSAppleM1|Jdk17|Maven3.8.5|SpringBoot2.6.9|neo4j5.10.0注:neo4j内嵌最大的坑就是版本兼容性,所以引入前一定检查neo4j与springboot版本兼容性,其次neo4j各版本间配置使用上,区别也挺大的,本文只针对特定版本,因此建议更多参考官网文档,有最新的配置......
  • jmeter详解-线程组详解(5)-jp@gc - Ultimate Thread Group
    添加方式:右键测试计划->添加->Threads(Users)->jp@gc-UltimateThreadGroup页面说明:StartThreadsCount:当前行的线程总数InitialDelay/sec:延时启动当前行的线程,单位:秒StartupTime/sec:启动当前行所有线程达峰值所需时间,单位:秒HoldLoadFor/sec:当前行线程达到峰值......
  • springboot添加启动事件监听
    当我们需要在springboot启动时做的第一件事,可以通过添加事件监听实现,具体如下:添加事件importorg.springframework.boot.context.event.ApplicationStartingEvent;importorg.springframework.context.ApplicationListener;publicclassMyEventimplementsApplicationLis......
  • Springboot 内嵌 Sqlite 配置使用
    版本号MacOSAppleM1|Jdk17|Maven3.8.5|SpringBoot2.6.9|Sqlite3.42.0.0pom.xml<dependencies><dependency><groupId>org.xerial</groupId><artifactId>sqlite-jdbc</artifactId>......
  • JAVAEE就业免费视频教程springboot综合案例
    day06_springboot综合案例资源权限管理查询资源权限查询资源权限执行流程编写PermissionMapper接口publicinterfacePermissionMapper{/***查询资源权限*/List<Permission>findAll();}编写PermissionServicepublicinterfacePermissionServi......