spring-boot 速成(9) druid+mybatis 多数据源及读写分离的处理

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 按上节继续学习,稍微复杂的业务系统,一般会将数据库按业务拆开,比如产品系统的数据库放在product db中,订单系统的数据库放在order db中...,然后,如果量大了,可能每个库还要考虑做读、写分离,以进一步提高系统性能,下面就来看看如何处理: 核心思路:配置多个数据源,然后利用RoutingDataSource结合AOP来动态切不同的库。

上节继续学习,稍微复杂的业务系统,一般会将数据库按业务拆开,比如产品系统的数据库放在product db中,订单系统的数据库放在order db中...,然后,如果量大了,可能每个库还要考虑做读、写分离,以进一步提高系统性能,下面就来看看如何处理:

核心思路:配置多个数据源,然后利用RoutingDataSource结合AOP来动态切不同的库。

要解决的问题:

1、配置文件中,多数据源的配置节点如何设计?

 1 druid:
 2     type: com.alibaba.druid.pool.DruidDataSource
 3     study:
 4       master: #study库的主库
 5         url: jdbc:mysql://localhost:3306/study?useSSL=false&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useUnicode=true
 6         driver-class-name: com.mysql.cj.jdbc.Driver
 7         username: root
 8         password: A1b2c3@def.com
 9         initial-size: 5
10         min-idle: 1
11         max-active: 20
12         test-on-borrow: true
13       slave: #study库的从库
14         url: jdbc:mysql://localhost:3306/study_slave?useSSL=false&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useUnicode=true
15         driver-class-name: com.mysql.cj.jdbc.Driver
16         username: root
17         password: A1b2c3@def.com
18         initial-size: 5
19         min-idle: 1
20         max-active: 20
21         test-on-borrow: true
22     product:
23       master: #product库的主库
24         url: jdbc:mysql://localhost:3306/product?useSSL=false&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useUnicode=true
25         driver-class-name: com.mysql.cj.jdbc.Driver
26         username: root
27         password: A1b2c3@def.com
28         initial-size: 5
29         min-idle: 1
30         max-active: 20
31         test-on-borrow: true
32       slave: #product库的从库
33         url: jdbc:mysql://localhost:3306/product_slave?useSSL=false&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useUnicode=true
34         driver-class-name: com.mysql.cj.jdbc.Driver
35         username: root
36         password: A1b2c3@def.com
37         initial-size: 5
38         min-idle: 1
39         max-active: 20
40         test-on-borrow: true
View Code

上面的配置写法供参数,如果slave节点数要扩展,按这个格式,改造成slave1,slave2... 自行扩展。

 

2、配置类如何设计?

 1 package com.cnblogs.yjmyzz.db.config;
 2 
 3 /**
 4  * Created by jimmy on 6/18/17.
 5  */
 6 
 7 import com.cnblogs.yjmyzz.db.datasource.DbContextHolder;
 8 import com.cnblogs.yjmyzz.db.datasource.MasterSlaveRoutingDataSource;
 9 import org.springframework.beans.factory.annotation.Value;
10 import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
11 import org.springframework.boot.context.properties.ConfigurationProperties;
12 import org.springframework.context.annotation.Bean;
13 import org.springframework.context.annotation.Configuration;
14 import org.springframework.context.annotation.Primary;
15 import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
16 import org.springframework.transaction.annotation.EnableTransactionManagement;
17 
18 import javax.sql.DataSource;
19 import java.util.HashMap;
20 import java.util.Map;
21 
22 
23 @Configuration
24 @EnableTransactionManagement
25 public class DataSourceConfiguration {
26 
27     @Value("${druid.type}")
28     private Class<? extends DataSource> dataSourceType;
29 
30     @Bean(name = "studyMasterDataSource")
31     @ConfigurationProperties(prefix = "druid.study.master")
32     public DataSource studyMasterDataSource() {
33         return DataSourceBuilder.create().type(dataSourceType).build();
34     }
35 
36     @Bean(name = "studySlaveDataSource")
37     @ConfigurationProperties(prefix = "druid.study.slave")
38     public DataSource studySlaveDataSource1() {
39         return DataSourceBuilder.create().type(dataSourceType).build();
40     }
41 
42     @Bean(name = "productMasterDataSource")
43     @ConfigurationProperties(prefix = "druid.product.master")
44     public DataSource productMasterDataSource() {
45         return DataSourceBuilder.create().type(dataSourceType).build();
46     }
47 
48     @Bean(name = "productSlaveDataSource")
49     @ConfigurationProperties(prefix = "druid.product.slave")
50     public DataSource productSlaveDataSource1() {
51         return DataSourceBuilder.create().type(dataSourceType).build();
52     }
53 
54     @Bean(name = "dataSource")
55     @Primary
56     public AbstractRoutingDataSource dataSource() {
57         MasterSlaveRoutingDataSource proxy = new MasterSlaveRoutingDataSource();
58         Map<Object, Object> targetDataResources = new HashMap<>();
59         targetDataResources.put(DbContextHolder.DbType.PRODUCT_MASTER, productMasterDataSource());
60         targetDataResources.put(DbContextHolder.DbType.PRODUCT_SLAVE, productSlaveDataSource1());
61         targetDataResources.put(DbContextHolder.DbType.STUDY_MASTER, studyMasterDataSource());
62         targetDataResources.put(DbContextHolder.DbType.STUDY_SLAVE, studySlaveDataSource1());
63         proxy.setDefaultTargetDataSource(productMasterDataSource());
64         proxy.setTargetDataSources(targetDataResources);
65         proxy.afterPropertiesSet();
66         return proxy;
67     }
68 
69 }
View Code

参考这个,一看就明,不说多(注:@Primary一定要在动态数据源上,否则事务回滚无效!)

 

3、根据什么来切换db?

有很多选择,

a、用约定的方法前缀,比如:get/query/list开头的约定为读从库,其它为主库,但是这样还要考虑不同业务库的切换(即:何时切换到product库,何时切换到order库,可以再用不同的Scanner来处理,略复杂)

b、用自定义注解来处理,比如 @ProductMaster注解,表示切换到product的master库,这样同时把业务库,以及主还是从,一次性解决了,推荐这种。

这里,我定义了4个注解,代表product,study二个库的主及从。

 

4、aop在哪里拦截,如何拦截?

service层和mapper层都可以拦截,推荐在服务层拦截,否则如果一个业务方法里,即有读又有写,还得考虑如果遇到事务,要考虑的东西更多。

当然,如果拦截特定的注解,就不用过多考虑在哪个层,只认注解就行(当然,注解还是建议打在服务层上)。

dubbo-starter的一个小坑:spring boot中,只有managed bean才能用aop拦截,而dubbo-starter中的@service注解不是spring中的注解(是阿里package下的自定义注解),生成的service provider实例,aop拦截不到,解决办法,再加一个注解让spring认识它,参考:

Aop拦截类的参考代码如下:

  1 package com.cnblogs.yjmyzz.db.aspect;
  2 
  3 import com.cnblogs.yjmyzz.db.annotation.ProductMaster;
  4 import com.cnblogs.yjmyzz.db.annotation.ProductSlave;
  5 import com.cnblogs.yjmyzz.db.annotation.StudyMaster;
  6 import com.cnblogs.yjmyzz.db.annotation.StudySlave;
  7 import com.cnblogs.yjmyzz.db.datasource.DbContextHolder;
  8 import org.aspectj.lang.ProceedingJoinPoint;
  9 import org.aspectj.lang.annotation.Around;
 10 import org.aspectj.lang.annotation.Aspect;
 11 import org.slf4j.Logger;
 12 import org.slf4j.LoggerFactory;
 13 import org.springframework.core.Ordered;
 14 import org.springframework.stereotype.Component;
 15 
 16 
 17 @Aspect
 18 @Component
 19 public class MasterSlaveAspect implements Ordered {
 20 
 21     public static final Logger logger = LoggerFactory.getLogger(MasterSlaveAspect.class);
 22 
 23 
 24     /**
 25      * 切换到product主库
 26      *
 27      * @param proceedingJoinPoint
 28      * @param productMaster
 29      * @return
 30      * @throws Throwable
 31      */
 32     @Around("@annotation(productMaster)")
 33     public Object proceed(ProceedingJoinPoint proceedingJoinPoint, ProductMaster productMaster) throws Throwable {
 34         try {
 35             logger.info("set database connection to product-master only");
 36             DbContextHolder.setDbType(DbContextHolder.DbType.PRODUCT_MASTER);
 37             Object result = proceedingJoinPoint.proceed();
 38             return result;
 39         } finally {
 40             DbContextHolder.clearDbType();
 41             logger.info("restore database connection");
 42         }
 43     }
 44 
 45 
 46     /**
 47      * 切换到product从库
 48      *
 49      * @param proceedingJoinPoint
 50      * @param productSlave
 51      * @return
 52      * @throws Throwable
 53      */
 54     @Around("@annotation(productSlave)")
 55     public Object proceed(ProceedingJoinPoint proceedingJoinPoint, ProductSlave productSlave) throws Throwable {
 56         try {
 57             logger.info("set database connection to product-slave only");
 58             DbContextHolder.setDbType(DbContextHolder.DbType.PRODUCT_SLAVE);
 59             Object result = proceedingJoinPoint.proceed();
 60             return result;
 61         } finally {
 62             DbContextHolder.clearDbType();
 63             logger.info("restore database connection");
 64         }
 65     }
 66 
 67     /**
 68      * 切换到study主库
 69      *
 70      * @param proceedingJoinPoint
 71      * @param studyMaster
 72      * @return
 73      * @throws Throwable
 74      */
 75     @Around("@annotation(studyMaster)")
 76     public Object proceed(ProceedingJoinPoint proceedingJoinPoint, StudyMaster studyMaster) throws Throwable {
 77         try {
 78             logger.info("set database connection to study-master only");
 79             DbContextHolder.setDbType(DbContextHolder.DbType.STUDY_MASTER);
 80             Object result = proceedingJoinPoint.proceed();
 81             return result;
 82         } finally {
 83             DbContextHolder.clearDbType();
 84             logger.info("restore database connection");
 85         }
 86     }
 87 
 88     /**
 89      * 切换到study从库
 90      *
 91      * @param proceedingJoinPoint
 92      * @param studySlave
 93      * @return
 94      * @throws Throwable
 95      */
 96     @Around("@annotation(studySlave)")
 97     public Object proceed(ProceedingJoinPoint proceedingJoinPoint, StudySlave studySlave) throws Throwable {
 98         try {
 99             logger.info("set database connection to study-slave only");
100             DbContextHolder.setDbType(DbContextHolder.DbType.STUDY_SLAVE);
101             Object result = proceedingJoinPoint.proceed();
102             return result;
103         } finally {
104             DbContextHolder.clearDbType();
105             logger.info("restore database connection");
106         }
107     }
108 
109     @Override
110     public int getOrder() {
111         return 0;
112     }
113 }
View Code

 

5、其它事项

启用类上,一定要排除spring-boot自带的datasource配置,即:

1 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
2 @EnableAspectJAutoProxy
3 @ComponentScan("com.cnblogs.yjmyzz")
4 @MapperScan(basePackages = "com.cnblogs.yjmyzz.dao.mapper")
5 public class ServiceProvider {
6     public static void main(String[] args) {
7         SpringApplication.run(ServiceProvider.class, args);
8     }
9 }
View Code

第1行:@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

 

6、日志中如何输出格式化且带参数值的sql?

一般的sql输出是这样的:

我们可以把它变成下面这样:

是不是更友好!

方法:加一个mybtais的拦截器即可

package com.cnblogs.yjmyzz.db.interceptor;


import com.cnblogs.yjmyzz.util.PrettySQLFormatter;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ParameterMapping;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.TypeHandlerRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Properties;


/**
 * Created by 菩提树下的杨过(http://yjmyzz.cnblogs.com/) on 28/07/2017.
 */
@Intercepts({
        @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}),
        @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
        @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class})})
public class MybatisInterceptor implements Interceptor {

    private static Logger logger = LoggerFactory.getLogger(MybatisInterceptor.class);

    private Properties properties;

    private final static SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
        Object parameter = null;
        if (invocation.getArgs().length > 1) {
            parameter = invocation.getArgs()[1];
        }
        String sqlId = mappedStatement.getId();
        BoundSql boundSql = mappedStatement.getBoundSql(parameter);
        Configuration configuration = mappedStatement.getConfiguration();
        Object returnValue;
        long start = System.currentTimeMillis();
        returnValue = invocation.proceed();
        long end = System.currentTimeMillis();
        long time = (end - start);
        if (time > 1) {
            String sql = getSql(configuration, boundSql, sqlId, time);
            logger.debug("mapper method ==> " + sql.split("\\^")[0] + "\n," + PrettySQLFormatter.getPrettySql(sql.split("\\^")[1]) + "\n\n," + "sql execute time ==> " + time + " ms\n\n");
        }
        return returnValue;
    }

    @Override
    public Object plugin(Object target) {
        return Plugin.wrap(target, this);
    }

    @Override
    public void setProperties(Properties properties) {
        this.properties = properties;
    }


    public static String getSql(Configuration configuration, BoundSql boundSql, String sqlId, long time) {
        String sql = showSql(configuration, boundSql);
        StringBuilder str = new StringBuilder(100);
        str.append(sqlId);
        str.append("^");
        str.append(sql);
        str.append("^");
        str.append(time);
        str.append("ms");
        return str.toString();
    }

    private static String getParameterValue(Object obj) {
        String value;
        if (obj instanceof String) {
            value = "'" + obj.toString() + "'";
        } else if (obj instanceof Date) {
            value = "'" + sdt.format(obj) + "'";
        } else {
            if (obj != null) {
                value = obj.toString();
            } else {
                value = "";
            }

        }
        return value;
    }

    public static String showSql(Configuration configuration, BoundSql boundSql) {
        Object parameterObject = boundSql.getParameterObject();
        List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
        String sql = boundSql.getSql().replaceAll("[\\s]+", " ");
        if (parameterMappings.size() > 0 && parameterObject != null) {
            TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
            if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
                sql = sql.replaceFirst("\\?", getParameterValue(parameterObject));

            } else {
                MetaObject metaObject = configuration.newMetaObject(parameterObject);
                for (ParameterMapping parameterMapping : parameterMappings) {
                    String propertyName = parameterMapping.getProperty();
                    if (metaObject.hasGetter(propertyName)) {
                        Object obj = metaObject.getValue(propertyName);
                        sql = sql.replaceFirst("\\?", getParameterValue(obj));
                    } else if (boundSql.hasAdditionalParameter(propertyName)) {
                        Object obj = boundSql.getAdditionalParameter(propertyName);
                        sql = sql.replaceFirst("\\?", getParameterValue(obj));
                    }
                }
            }
        }
        return sql;
    }
}

这里面还用了hibernate的一个小工具,用于格式化sql

package com.cnblogs.yjmyzz.util;

import org.hibernate.engine.jdbc.internal.FormatStyle;

public class PrettySQLFormatter {

    public static void print(String sql) {
        System.out.println(FormatStyle.BASIC.getFormatter().format(sql));
    }


    public static void print(String remark, String sql) {
        System.out.println(remark
                + FormatStyle.BASIC.getFormatter().format(sql));
    }


    public static String getPrettySql(String sql) {
        return FormatStyle.BASIC.getFormatter().format(sql);
    }


    public static String getPrettySql(String remark, String sql) {
        return remark + FormatStyle.BASIC.getFormatter().format(sql);
    }

    public static void main(String[] args) {
        System.out.println(getPrettySql("select * from MyUser as A join MyFriend as B on A.id = B.pid where B.name like ? "));
    }
}

接下来,把这个拦截器配置在mybatis-config.xml里

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
 3         "http://mybatis.org/dtd/mybatis-3-config.dtd">
 4 <configuration>
 5     <settings>
 6         <setting name="cacheEnabled" value="true"/>
 7     </settings>
 8 
 9     <plugins>
10         <plugin interceptor="com.cnblogs.yjmyzz.db.interceptor.MybatisInterceptor">
11         </plugin>
12     </plugins>
13 
14 </configuration>
View Code

最后在application.yml里指定mybatis-config.xml所在的路径:

示例源码见:https://github.com/yjmyzz/spring-boot-dubbo-demo (dubbox2.8.5-multi-ds分支)

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
38
分享
相关文章
微服务——SpringBoot使用归纳——Spring Boot集成MyBatis——基于 xml 的整合
本教程介绍了基于XML的MyBatis整合方式。首先在`application.yml`中配置XML路径,如`classpath:mapper/*.xml`,然后创建`UserMapper.xml`文件定义SQL映射,包括`resultMap`和查询语句。通过设置`namespace`关联Mapper接口,实现如`getUserByName`的方法。Controller层调用Service完成测试,访问`/getUserByName/{name}`即可返回用户信息。为简化Mapper扫描,推荐在Spring Boot启动类用`@MapperScan`注解指定包路径避免逐个添加`@Mapper`
37 0
微服务——SpringBoot使用归纳——Spring Boot集成MyBatis——基于注解的整合
本文介绍了Spring Boot集成MyBatis的两种方式:基于XML和注解的形式。重点讲解了注解方式,包括@Select、@Insert、@Update、@Delete等常用注解的使用方法,以及多参数时@Param注解的应用。同时,针对字段映射不一致的问题,提供了@Results和@ResultMap的解决方案。文章还提到实际项目中常结合XML与注解的优点,灵活使用两者以提高开发效率,并附带课程源码供下载学习。
27 0
微服务——SpringBoot使用归纳——Spring Boot集成MyBatis——MyBatis 介绍和配置
本文介绍了Spring Boot集成MyBatis的方法,重点讲解基于注解的方式。首先简述MyBatis作为持久层框架的特点,接着说明集成时的依赖导入,包括`mybatis-spring-boot-starter`和MySQL连接器。随后详细展示了`properties.yml`配置文件的内容,涵盖数据库连接、驼峰命名规范及Mapper文件路径等关键设置,帮助开发者快速上手Spring Boot与MyBatis的整合开发。
63 0
对Spring、SpringMVC、MyBatis框架的介绍与解释
Spring 框架提供了全面的基础设施支持,Spring MVC 专注于 Web 层的开发,而 MyBatis 则是一个高效的持久层框架。这三个框架结合使用,可以显著提升 Java 企业级应用的开发效率和质量。通过理解它们的核心特性和使用方法,开发者可以更好地构建和维护复杂的应用程序。
159 29
Java后端开发-使用springboot进行Mybatis连接数据库步骤
本文介绍了使用Java和IDEA进行数据库操作的详细步骤,涵盖从数据库准备到测试类编写及运行的全过程。主要内容包括: 1. **数据库准备**:创建数据库和表。 2. **查询数据库**:验证数据库是否可用。 3. **IDEA代码配置**:构建实体类并配置数据库连接。 4. **测试类编写**:编写并运行测试类以确保一切正常。
121 2
Spring Boot 3 整合 Mybatis-Plus 实现数据权限控制
本文介绍了如何在Spring Boot 3中整合MyBatis-Plus实现数据权限控制,通过使用MyBatis-Plus提供的`DataPermissionInterceptor`插件,在不破坏原有代码结构的基础上实现了细粒度的数据访问控制。文中详细描述了自定义注解`DataScope`的使用方法、`DataPermissionHandler`的具体实现逻辑,以及根据用户的不同角色和部门动态添加SQL片段来限制查询结果。此外,还展示了基于Spring Boot 3和Vue 3构建的前后端分离快速开发框架的实际应用案例,包括项目的核心功能模块如用户管理、角色管理等,并提供Gitee上的开源仓库
531 11
深入探讨:Spring与MyBatis中的连接池与缓存机制
Spring 与 MyBatis 提供了强大的连接池和缓存机制,通过合理配置和使用这些机制,可以显著提升应用的性能和可扩展性。连接池通过复用数据库连接减少了连接创建和销毁的开销,而 MyBatis 的一级缓存和二级缓存则通过缓存查询结果减少了数据库访问次数。在实际应用中,结合具体的业务需求和系统架构,优化连接池和缓存的配置,是提升系统性能的重要手段。
207 4
mybatis使用一:springboot整合mybatis、mybatis generator,使用逆向工程生成java代码。
这篇文章介绍了如何在Spring Boot项目中整合MyBatis和MyBatis Generator,使用逆向工程来自动生成Java代码,包括实体类、Mapper文件和Example文件,以提高开发效率。
258 2
mybatis使用一:springboot整合mybatis、mybatis generator,使用逆向工程生成java代码。
|
6月前
|
mybatis使用三:springboot整合mybatis,使用PageHelper 进行分页操作,并整合swagger2。使用正规的开发模式:定义统一的数据返回格式和请求模块
这篇文章介绍了如何在Spring Boot项目中整合MyBatis和PageHelper进行分页操作,并且集成Swagger2来生成API文档,同时定义了统一的数据返回格式和请求模块。
166 1
mybatis使用三:springboot整合mybatis,使用PageHelper 进行分页操作,并整合swagger2。使用正规的开发模式:定义统一的数据返回格式和请求模块
Springboot整合shiro,带你学会shiro,入门级别教程,由浅入深,完整代码案例,各位项目想加这个模块的人也可以看这个,又或者不会mybatis-plus的也可以看这个
本文详细讲解了如何整合Apache Shiro与Spring Boot项目,包括数据库准备、项目配置、实体类、Mapper、Service、Controller的创建和配置,以及Shiro的配置和使用。
1241 1
Springboot整合shiro,带你学会shiro,入门级别教程,由浅入深,完整代码案例,各位项目想加这个模块的人也可以看这个,又或者不会mybatis-plus的也可以看这个

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等