springbootmybatisplus集成shiro实现权限控制(代码片段)

风之丘666 风之丘666     2022-12-01     135

关键词:

1.创建数据库表。由于时间仓促,数据库表设计不太合理,后期会更改

/*
 Navicat Premium Data Transfer

 Source Server         : 本地
 Source Server Type    : MySQL
 Source Server Version : 80021
 Source Host           : localhost:3306
 Source Schema         : logindatabase

 Target Server Type    : MySQL
 Target Server Version : 80021
 File Encoding         : 65001

 Date: 23/06/2021 15:25:59
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for sys_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu`  (
  `id` int(0) NOT NULL AUTO_INCREMENT COMMENT \'主键\',
  `menu_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'菜单名称\',
  `permission_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'权限ID\',
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'请求路径\',
  `sort` tinyint(0) NULL DEFAULT NULL COMMENT \'排序\',
  `style` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'样式(可设置css图标)\',
  `parent_id` int(0) NULL DEFAULT NULL COMMENT \'父主键ID(有值的,属于该值菜单的下级菜单)\',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'创建人\',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT \'创建时间\',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'修改人\',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT \'修改时间\',
  `is_deleted` tinyint(0) UNSIGNED NULL DEFAULT 0 COMMENT \'是否删除(0:正常/1:删除)\',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = \'菜单表\' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sys_menu
-- ----------------------------
INSERT INTO `sys_menu` VALUES (1, \'系统管理\', \'10001\', NULL, 1, NULL, NULL, \'88888888\', \'2021-03-23 15:09:11\', NULL, NULL, 0);
INSERT INTO `sys_menu` VALUES (2, \'权限管理\', \'10002\', \'/sys/permission\', 2, NULL, 1, \'88888888\', \'2021-03-23 15:09:11\', NULL, NULL, 0);
INSERT INTO `sys_menu` VALUES (3, \'角色管理\', \'10003\', \'/sys/role\', 3, NULL, 1, \'88888888\', \'2021-03-23 15:09:11\', NULL, NULL, 0);
INSERT INTO `sys_menu` VALUES (4, \'用户管理\', \'10004\', \'/sys/user\', 4, NULL, 1, \'88888888\', \'2021-03-23 15:09:11\', NULL, NULL, 0);

-- ----------------------------
-- Table structure for sys_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_permission`;
CREATE TABLE `sys_permission`  (
  `id` int(0) NOT NULL AUTO_INCREMENT COMMENT \'主键\',
  `permission_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT \'权限编码\',
  `permission_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'权限名称\',
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'描述说明\',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'创建人\',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT \'创建时间\',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'修改人\',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT \'修改时间\',
  `is_deleted` tinyint(0) UNSIGNED NULL DEFAULT 0 COMMENT \'是否删除(0:正常/1:删除)\',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = \'权限表\' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sys_permission
-- ----------------------------
INSERT INTO `sys_permission` VALUES (1, \'sys:controller\', \'系统管理\', \'菜单权限(一级菜单)\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (2, \'per:controller\', \'权限管理\', \'菜单权限(二级菜单)\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (3, \'role:controller\', \'角色管理\', \'菜单权限(二级菜单)\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (4, \'user:controller\', \'用户管理\', \'菜单权限(二级菜单)\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (5, \'admin\', \'超级管理员\', \'当用户角色拥有该权限时,可分配sys_role表中权限ID为该值的角色给用户\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (6, \'group\', \'组长管理员\', \'组长角色拥有该权限时,可分配测试员的角色给用户\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (7, \'list:view\', \'查询权限列表\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (8, \'per:add\', \'新增权限\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (9, \'per:edit\', \'修改权限\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (10, \'per:delete\', \'删除权限\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (11, \'role:view\', \'查询角色列表\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (12, \'role:add\', \'新增角色\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (13, \'role:edit\', \'修改角色\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (14, \'role:delete\', \'删除角色\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (15, \'user:list\', \'查询用户列表\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (16, \'user:add\', \'新增用户\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (17, \'user:edit\', \'修改用户\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);
INSERT INTO `sys_permission` VALUES (18, \'user:delete\', \'删除用户\', \'接口权限\', \'88888888\', \'2021-03-23 15:11:42\', NULL, NULL, 0);

-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role`  (
  `id` int(0) NOT NULL AUTO_INCREMENT COMMENT \'主键\',
  `role_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'角色code\',
  `role_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'角色名称\',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'创建人\',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT \'创建时间\',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'修改人\',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT \'修改时间\',
  `is_deleted` tinyint(1) NULL DEFAULT 0 COMMENT \'是否删除(0:正常/1:删除)\',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = \'角色表\' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sys_role
-- ----------------------------
INSERT INTO `sys_role` VALUES (1, \'admin\', \'超级管理员\', \'88888888\', \'2021-03-23 15:18:10\', NULL, NULL, 0);
INSERT INTO `sys_role` VALUES (2, \'group\', \'组长\', \'88888888\', \'2021-03-23 15:18:10\', NULL, NULL, 0);
INSERT INTO `sys_role` VALUES (3, \'test\', \'测试员\', \'88888888\', \'2021-03-23 15:18:10\', NULL, NULL, 0);

-- ----------------------------
-- Table structure for sys_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_permission`;
CREATE TABLE `sys_role_permission`  (
  `id` int(0) NOT NULL AUTO_INCREMENT COMMENT \'主键\',
  `role_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'角色ID\',
  `permission_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'权限ID\',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'创建人\',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT \'创建时间\',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'修改人\',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT \'修改时间\',
  `is_deleted` tinyint(1) NULL DEFAULT 0 COMMENT \'是否删除(0:正常/1:删除)\',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = \'角色权限关联表\' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sys_role_permission
-- ----------------------------
INSERT INTO `sys_role_permission` VALUES (1, \'1\', \'1\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (2, \'2\', \'2\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (3, \'3\', \'3\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (4, \'1\', \'4\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (5, \'1\', \'5\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (6, \'1\', \'6\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (7, \'2\', \'7\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (8, \'2\', \'8\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (9, \'2\', \'9\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (10, \'3\', \'10\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (11, \'3\', \'11\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (12, \'3\', \'12\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (13, \'1\', \'13\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (14, \'1\', \'14\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (15, \'1\', \'15\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (16, \'2\', \'16\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (17, \'1\', \'17\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (18, \'1\', \'18\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (19, \'2\', \'13\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (20, \'2\', \'14\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (21, \'2\', \'15\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (22, \'2\', \'10\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (23, \'3\', \'11\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);
INSERT INTO `sys_role_permission` VALUES (24, \'3\', \'12\', \'1\', \'2021-03-23 15:29:09\', NULL, NULL, 0);

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user`  (
  `id` int(0) NOT NULL AUTO_INCREMENT COMMENT \'主键\',
  `user_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'用户名称\',
  `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'密码\',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'创建人\',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT \'创建时间\',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'修改人\',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT \'修改时间\',
  `is_deleted` tinyint(1) NULL DEFAULT 0 COMMENT \'是否删除(0:正常/1:删除)\',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = \'用户表\' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES (1, \'超级管理员\', \'88888888\', \'88888888\', \'2021-03-23 15:51:27\', NULL, NULL, 0);
INSERT INTO `sys_user` VALUES (2, \'张三\', \'123456\', \'88888888\', \'2021-03-23 15:51:27\', NULL, NULL, 0);
INSERT INTO `sys_user` VALUES (3, \'李四\', \'123456\', \'88888888\', \'2021-03-23 15:51:27\', NULL, NULL, 0);
INSERT INTO `sys_user` VALUES (4, \'王五\', \'123456\', \'88888888\', \'2021-03-23 15:51:27\', NULL, NULL, 0);

-- ----------------------------
-- Table structure for sys_user_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role`  (
  `id` int(0) NOT NULL AUTO_INCREMENT COMMENT \'主键\',
  `user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'用户ID\',
  `role_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'角色ID\',
  `create_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'创建人\',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT \'创建时间\',
  `update_user` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT \'修改人\',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT \'修改时间\',
  `is_deleted` tinyint(1) NULL DEFAULT 0 COMMENT \'是否删除(0:正常/1:删除)\',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = \'用户角色关联表\' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of sys_user_role
-- ----------------------------
INSERT INTO `sys_user_role` VALUES (1, \'1\', \'1\', \'1\', \'2021-03-23 15:54:17\', NULL, NULL, 0);
INSERT INTO `sys_user_role` VALUES (2, \'2\', \'2\', \'1\', \'2021-03-23 15:54:17\', NULL, NULL, 0);
INSERT INTO `sys_user_role` VALUES (3, \'3\', \'3\', \'1\', \'2021-03-23 15:54:17\', NULL, NULL, 0);
INSERT INTO `sys_user_role` VALUES (4, \'4\', \'1\', \'1\', \'2021-03-23 15:54:17\', NULL, NULL, 0);
INSERT INTO `sys_user_role` VALUES (5, \'4\', \'2\', \'1\', \'2021-03-23 15:54:17\', NULL, NULL, 0);
INSERT INTO `sys_user_role` VALUES (6, \'1\', \'3\', \'1\', \'2021-03-23 15:54:17\', NULL, NULL, 0);
INSERT INTO `sys_user_role` VALUES (7, \'1\', \'2\', \'1\', \'2021-03-23 15:54:17\', NULL, NULL, 0);

SET FOREIGN_KEY_CHECKS = 1;

2.pom文件

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- shiro start -->
    <dependency>
        <groupId>org.apache.shiro</groupId>
        <artifactId>shiro-spring</artifactId>
        <version>1.3.2</version>
    </dependency>
    <!-- shiro end -->
    <!-- mysql start -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <!-- mysql end -->
    <!-- mybatis-plus start -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.2.0</version>
    </dependency>
    <!-- mybatis-plus end -->
    <!-- mybatis-plus代码生成 start -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-generator</artifactId>
        <version>3.2.0</version>
    </dependency>
    <!-- mybatis-plus代码生成 end -->
    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.28</version>
    </dependency>
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.47</version>
    </dependency>
</dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

3.代码生成(网上找的别人的)

public class GeneratorCodeConfig 

    public static String scanner(String tip) 
        Scanner scanner = new Scanner(System.in);
        StringBuilder help = new StringBuilder();
        help.append("请输入" + tip + ":");
        System.out.println(help.toString());
        if (scanner.hasNext()) 
            String ipt = scanner.next();
            if (StringUtils.isNotEmpty(ipt)) 
                return ipt;
            
        
        throw new MybatisPlusException("请输入正确的" + tip + "!");
    

    public static void main(String[] args) 
        // 代码生成器
        AutoGenerator mpg = new AutoGenerator();

        // 全局配置
        GlobalConfig gc = new GlobalConfig();
        String projectPath = System.getProperty("user.dir");
        gc.setOutputDir(projectPath + "/src/main/java");
        gc.setAuthor("zk");
        gc.setOpen(false);
        //实体属性 Swagger2 注解
        gc.setSwagger2(false);
        mpg.setGlobalConfig(gc);

        // 数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl("jdbc:mysql://127.0.0.1:3306/logindatabase?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true");
        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
        dsc.setUsername("root");
        dsc.setPassword("root1234");
        mpg.setDataSource(dsc);

        // 包配置
        PackageConfig pc = new PackageConfig();
//        pc.setModuleName(scanner("模块名"));
        pc.setParent("com.example");
        pc.setEntity("model");
        pc.setMapper("mapper");
        pc.setService("service");
        pc.setServiceImpl("service.impl");
        mpg.setPackageInfo(pc);

        // 自定义配置
//        InjectionConfig cfg = new InjectionConfig() 
//            @Override
//            public void initMap() 
//                // to do nothing
//            
//        ;

        // 如果模板引擎是 freemarker
//        String templatePath = "/templates/mapper.xml.ftl";
        // 如果模板引擎是 velocity
        // String templatePath = "/templates/mapper.xml.vm";

        // 自定义输出配置
//        List<FileOutConfig> focList = new ArrayList<>();
        // 自定义配置会被优先输出
//        focList.add(new FileOutConfig(templatePath) 
//            @Override
//            public String outputFile(TableInfo tableInfo) 
//                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
//                return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
//                        + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
//            
//        );
        /*
        cfg.setFileCreate(new IFileCreate() 
            @Override
            public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) 
                // 判断自定义文件夹是否需要创建
                checkDir("调用默认方法创建的目录");
                return false;
            
        );
        */
//        cfg.setFileOutConfigList(focList);
//        mpg.setCfg(cfg);

        // 配置模板
        TemplateConfig templateConfig = new TemplateConfig();

        // 配置自定义输出模板
        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
        // templateConfig.setEntity("templates/entity2.java");
        // templateConfig.setService();
        // templateConfig.setController();

        templateConfig.setXml(null);
        mpg.setTemplate(templateConfig);

        // 策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setNaming(NamingStrategy.underline_to_camel);
        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
        strategy.setSuperEntityClass("com.baomidou.mybatisplus.extension.activerecord.Model");
        strategy.setEntityLombokModel(true);
        strategy.setRestControllerStyle(true);

        strategy.setEntityLombokModel(true);
        // 公共父类
//        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
        // 写于父类中的公共字段
//        strategy.setSuperEntityColumns("id");
        strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
        strategy.setControllerMappingHyphenStyle(true);
        strategy.setTablePrefix(pc.getModuleName() + "_");
        mpg.setStrategy(strategy);
        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
        mpg.execute();
    

4.mybatis分页插件

@Configuration
public class MybatisPlusConfig 

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() 
        return new PaginationInterceptor();
    

5.添加shiro配置类

@Configuration
public class ShiroConfig 

    @Bean
    public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) 
        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
        // 必须设置 SecurityManager
        shiroFilterFactoryBean.setSecurityManager(securityManager);
        // setLoginUrl 如果不设置值,默认会自动寻找Web工程根目录下的"/login.jsp"页面 或 "/login" 映射
        shiroFilterFactoryBean.setLoginUrl("/notLogin");
        // 设置无权限时跳转的 url;
        shiroFilterFactoryBean.setUnauthorizedUrl("/notRole");

        // 设置拦截器
        Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
        //开放登陆接口
        filterChainDefinitionMap.put("/login", "anon");
        //其余接口一律拦截
        //主要这行代码必须放在所有权限设置的最后,不然会导致所有 url 都被拦截
        filterChainDefinitionMap.put("/**", "authc");

        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
        System.out.println("Shiro拦截器工厂类注入成功");
        return shiroFilterFactoryBean;
    

    /**
     * 注入 securityManager
     */
    @Bean
    public SecurityManager securityManager() 
        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
        // 设置realm.
        securityManager.setRealm(customRealm());
        return securityManager;
    

    /**
     * 自定义身份认证 realm;
     * <p>
     * 必须写这个类,并加上 @Bean 注解,目的是注入 CustomRealm,
     * 否则会影响 CustomRealm类 中其他类的依赖注入
     */
    @Bean
    public CustomRealm customRealm() 
        return new CustomRealm();
    

    /**
     *  开启Shiro的注解(如@RequiresRoles,@RequiresPermissions)
     * @return
     */
    @Bean
    public DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator()
        DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
        advisorAutoProxyCreator.setProxyTargetClass(true);
        return advisorAutoProxyCreator;
    

    /**
     * 开启aop注解支持
     * @param securityManager
     * @return
     */
    @Bean
    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) 
        AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
        authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
        return authorizationAttributeSourceAdvisor;
    

6.创建CustomRealm用于用户验证和权限控制

public class CustomRealm extends AuthorizingRealm 

    @Autowired
    private ISysUserService userService;

    @Autowired
    private ISysPermissionService sysPermissionService;

    /**
     * 获取身份验证信息
     * Shiro中,最终是通过 Realm 来获取应用程序中的用户、角色及权限信息的。
     *
     * @param authenticationToken 用户身份信息 token
     * @return 返回封装了用户信息的 AuthenticationInfo 实例
     */
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException 
        System.out.println("————身份认证方法————");
        String password = "";
        UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
        // 从数据库获取对应用户名密码的用户
        QueryWrapper query = new QueryWrapper();
        query.eq("user_name",token.getUsername());
        SysUser user = userService.getOne(query);
        if (user != null)
            password = user.getPassword();
            if (null == password) 
                throw new AccountException("用户名不正确");
             else if (!password.equals(new String((char[]) token.getCredentials()))) 
                throw new AccountException("密码不正确");
            
        else 
            throw new AccountException("该用户不存在");
        
        // 第一个参数保存为当前登陆人信息就可以使用 SecurityUtils.getSubject().getPrincipal() 获取登陆人信息
        return new SimpleAuthenticationInfo(user, password, getName());
    

    /**
     * 获取授权信息
     *
     * @param principalCollection
     * @return
     */
    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) 
        System.out.println("————权限认证————");
        String username = (String) SecurityUtils.getSubject().getPrincipal();
        SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
        //获得该用户角色
        Set<SysRole> sets = userService.getRole(username);

        Set<String> set = sets.stream().map(SysRole::getRoleCode).collect(Collectors.toSet());
        Set<Integer> roleIds = sets.stream().map(SysRole::getId).collect(Collectors.toSet());
        //设置该用户拥有的角色
        info.setRoles(set);
        Set<String> permissionSet = sysPermissionService.getPermissionByRole(roleIds);
        info.setStringPermissions(permissionSet);
        return info;
    

7.service
ISysUserService

public interface ISysUserService extends IService<SysUser> 

    Set<SysRole> getRole(String username);

ISysPermissionService

public interface ISysPermissionService extends IService<SysPermission> 

    Set<String> getPermissionByRole(Set<Integer> sets);

8.serviceImpl
ISysUserServiceImpl

@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService 

    @Autowired
    private SysUserMapper userMapper;

    @Override
    public Set<SysRole> getRole(String username) 
        return userMapper.getRole(username);
    

ISysPermissionServiceImpl

@Service
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements ISysPermissionService 

    @Autowired
    private SysPermissionMapper sysPermissionMapper;

    @Override
    public Set<String> getPermissionByRole(Set<Integer> sets) 
        return sysPermissionMapper.getPermissionByRole(sets);
    

9.mapper
ISysUserMapper

@Repository
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> 

    Set<SysRole> getRole(String username);

ISysPermissionMapper

@Repository
@Mapper
public interface SysPermissionMapper extends BaseMapper<SysPermission> 

    Set<String> getPermissionByRole(@Param("set") Set<Integer> sets);

10.mapper.xml
SysUserMapper

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.example.mapper.SysUserMapper">

    <select id="getRole" resultType="com.example.model.SysRole">
        SELECT r.* FROM `sys_user_role` AS ur JOIN sys_role AS r ON ur.role_id = r.id WHERE ur.user_id = (SELECT id FROM sys_user WHERE user_name = #username)
    </select>


</mapper>

SysPermissionMapper

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.example.mapper.SysPermissionMapper">

    <select id="getPermissionByRole" parameterType="java.util.Set" resultType="string">
        SELECT
            permission_code AS permissionCode
        FROM
            sys_permission
        WHERE
            id IN (
        SELECT
        permission_id
        FROM
        `sys_role_permission`
        WHERE
        <choose>
            <when test="set !=null and set.size()>0">
                role_id in
                <foreach item="id" index="index" collection="set" open="(" separator="," close=")">
                    #id
                </foreach>
            </when>
            <otherwise>
                0 = 1
            </otherwise>
        </choose>
         )

    </select>
</mapper>

11.yml

server:
  port: 8081
  servlet:
    context-path: /

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/logindatabase?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: root1234

mybatis-plus:
  configuration:
    map-underscore-to-camel-case: true
    auto-mapping-behavior: full
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath*:mapping/*Mapper.xml
  global-config:
    db-config:
      logic-not-delete-value: 1
      logic-delete-value: 0

12.编写登录controller

package com.example.controller;

import com.example.result.ResultInfo;
import com.example.result.Status;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zk
 * @Classname LoginController
 * @Description TODO
 * @Date 2021/6/11 17:17
 */
@RestController
public class LoginController 

    @RequestMapping(value = "/notLogin", method = RequestMethod.GET)
    public ResultInfo notLogin() 
        return new ResultInfo(Status.SUCCESS.code,"您尚未登陆!");
    

    @RequestMapping(value = "/notRole", method = RequestMethod.GET)
    public ResultInfo notRole() 
        return new ResultInfo(Status.SUCCESS.code,"您没有权限!");
    

    @RequestMapping(value = "/logout", method = RequestMethod.GET)
    public ResultInfo logout() 
        Subject subject = SecurityUtils.getSubject();
        //注销
        subject.logout();
        return new ResultInfo(Status.SUCCESS.code,"成功注销!");
    

    /**
     * 登陆
     *
     * @param username 用户名
     * @param password 密码
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public ResultInfo login(String username, String password) 
        // 从SecurityUtils里边创建一个 subject
        Subject subject = SecurityUtils.getSubject();
        // 在认证提交前准备 token(令牌)
        UsernamePasswordToken token = new UsernamePasswordToken(username, password);
        // 执行认证登陆
        subject.login(token);
        return new ResultInfo(Status.SUCCESS.code,"登录成功");
    

13.编写异常处理ExceptionController

package com.example.controller;

import com.example.result.ResultInfo;
import com.example.result.Status;
import org.apache.shiro.authc.AccountException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zk
 * @Classname ExceptionController
 * @Description TODO
 * @Date 2021/6/11 17:14
 */
@RestControllerAdvice
public class ExceptionController 

    @Autowired
    private ResultInfo resultInfo;

    @Autowired
    public ExceptionController(ResultInfo resultMap) 
        this.resultInfo = resultMap;
    

    // 捕捉 CustomRealm 抛出的异常
    @ExceptionHandler(AccountException.class)
    public ResultInfo handleShiroException(Exception ex) 
        return new ResultInfo(Status.SYSTEM_ERROR.code,ex.getMessage());
    

    /**
     * 访问接口没有权限
     * @param e
     * @return
     */
    @ExceptionHandler(UnauthorizedException.class)
    public ResultInfo handleShiroException1(Exception e) 
        return new ResultInfo(Status.INSUFFICIENT_PERMISSION.code,e.getMessage()+"---"+Status.INSUFFICIENT_PERMISSION.message);
    

14.返回结果封装类以及返回码枚举类

package com.example.result;

import lombok.Data;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * @author zk
 * @Classname ResultInfo
 * @Description 返回参数格式封装类
 * @Date 2021/6/11 11:28
 */
@Data
@Component
public class ResultInfo implements Serializable 

    // 状态码
    private Integer code;
    // 消息
    private String message;
    // 数据对象
    private Object result;

    /**
     * 无参构造器
     */
    public ResultInfo() 
        super();
    

    public ResultInfo(Status status) 
        super();
        this.code = status.code;
        this.message = status.message;
    

    public ResultInfo result(Object result) 
        this.result = result;
        return this;
    

    public ResultInfo message(String message) 
        this.message = message;
        return this;
    

    /**
     * 只返回状态,状态码,消息
     *
     * @param code
     * @param message
     */
    public ResultInfo(Integer code, String message) 
        super();
        this.code = code;
        this.message = message;
    

    /**
     * 只返回状态,状态码,数据对象
     *
     * @param code
     * @param result
     */
    public ResultInfo(Integer code, Object result) 
        super();
        this.code = code;
        this.result = result;
    

    /**
     * 返回全部信息即状态,状态码,消息,数据对象
     *
     * @param code
     * @param message
     * @param result
     */
    public ResultInfo(Integer code, String message, Object result) 
        super();
        this.code = code;
        this.message = message;
        this.result = result;
    

package com.example.result;

/**
 * @author zk
 * @Classname Status
 * @Description 返回值状态
 * @Date 2021/6/11 11:29
 */
public enum Status 

    // 公共
    SUCCESS(2000, "成功"),
    UNKNOWN_ERROR(9998,"未知异常"),
    SYSTEM_ERROR(9999, "系统异常"),


    INSUFFICIENT_PERMISSION(4003, "权限不足"),

    WARN(9000, "失败"),
    REQUEST_PARAMETER_ERROR(1002, "请求参数错误"),

    // 登录
    LOGIN_EXPIRE(2001, "未登录或者登录失效"),
    LOGIN_CODE_ERROR(2002, "登录验证码错误"),
    LOGIN_ERROR(2003, "用户名不存在或密码错误"),
    LOGIN_USER_STATUS_ERROR(2004, "用户状态不正确"),
    LOGOUT_ERROR(2005, "退出失败,token不存在"),
    LOGIN_USER_NOT_EXIST(2006, "该用户不存在"),
    LOGIN_USER_EXIST(2007, "该用户已存在");

    public int code;
    public String message;

    Status(int code, String message) 
        this.code = code;
        this.message = message;
    

最后附上实体类

package com.example.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @author zk
 * @since 2021-06-22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SysUser extends Model 

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 用户名称
     */
    private String userName;

    /**
     * 密码
     */
    private String password;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 修改人
     */
    private String updateUser;

    /**
     * 修改时间
     */
    private LocalDateTime updateTime;

    /**
     * 是否删除(0:正常/1:删除)
     */
    private Boolean isDeleted;



package com.example.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * <p>
 * 权限表
 * </p>
 *
 * @author zk
 * @since 2021-06-22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@NoArgsConstructor
public class SysPermission extends Model 

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 权限code
     */
    private String permissionCode;

    /**
     * 权限名称
     */
    private String permissionName;

    /**
     * 描述说明
     */
    private String description;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 修改人
     */
    private String updateUser;

    /**
     * 修改时间
     */
    private LocalDateTime updateTime;

    /**
     * 是否删除(0:正常/1:删除)
     */
    private Integer isDeleted;



刚开始写博客,只是用来平时记录,如果有什么遗漏或有问题的地方,希望各位大佬指出,谢谢。代码已上传至码云,地址https://gitee.com/ObjectKang/shirodemo

springbootmybatisplus报错,依赖冲突问题。

      今天使用springBoot热部署插件,引入了依赖,然后发现 查询mybatis报错,描述是 一个字段不存在,各种检查相关配置和数据库,都没有问题。然后深入查找,发现下面的依赖和mybatisplus冲突了。&n... 查看详情

先让springbootmybatisplus跑起来(代码片段)

架空一切前提条件,只讲怎么让它跑起来,实现基本的增删改查操作!架空一切前提条件,只讲怎么让它跑起来,实现基本的增删改查操作!假设:1、MySQL里已经有一张user表;2、已经安装IDEA;3、已经新建一个SpringBoot项目;4、... 查看详情

sh在群集中集成azure身份(代码片段)

查看详情

sh为line集成初始化redis(代码片段)

查看详情

sh从iterm2卸载shell集成(代码片段)

查看详情

电商项目后端框架springbootmybatisplus(代码片段)

后端框架基础1.代码自动生成工具mybatis-plus(1)首先需要添加依赖文件<dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.2.2</version></dependency><dependency><groupId>mysql&l... 查看详情

sh重置集成dell远程访问控制器(idrac6)的密码(代码片段)

查看详情

Xcode Server 持续集成和 cocoa pods 问题 Pods-resources.sh: Permission denied

】XcodeServer持续集成和cocoapods问题Pods-resources.sh:Permissiondenied【英文标题】:XcodeServercontinuousintegrationandcocoapodsissuePods-resources.sh:Permissiondenied【发布时间】:2014-12-3008:16:57【问题描述】:我正在使用XcodeServer构建自动化项目,其中... 查看详情

sh一个bash脚本,用于在ubuntu上设置onedrive与gnome的集成。(代码片段)

查看详情

springbootmybatisplus代码自动生成工具类(代码片段)

文章目录前言一、pom依赖二、工具类结尾前言代码生成器,也叫逆向工程,是根据数据库里的表结构,自动生成对应的实体类、映射文件和接口。看到很多小伙伴在为数据库生成实体类发愁,现分享给大家,... 查看详情

springbootmybatisplus代码自动生成工具类(代码片段)

文章目录前言一、pom依赖二、工具类结尾前言代码生成器,也叫逆向工程,是根据数据库里的表结构,自动生成对应的实体类、映射文件和接口。看到很多小伙伴在为数据库生成实体类发愁,现分享给大家,... 查看详情

springboot集成kafka(代码片段)

SpringBoot集成Kafka1安装Kafka2创建Topic3Java创建Topic4SpringBoot项目4.1pom.xml4.2application.yml4.3KafkaApplication.java4.4CustomizePartitioner.java4.5KafkaInitialConfig.java4.6SendMessageController.java5测试1安装KafkaDocker安装Kafka2创建Topic创建两个topic:topic1、topic... 查看详情

点燃集群和 Kubernetes 集成

】点燃集群和Kubernetes集成【英文标题】:igniteclusterandkubernetesintegration【发布时间】:2019-05-0104:41:26【问题描述】:我是Ignite的新手。Test1:(没有Kubernetes)步骤1:我在2个虚拟机(ubuntu)中安装了Ignite2.6.0,在一个虚拟机中启动... 查看详情

spring集成memcache实例

一、Memcache安装 下载地址:https://github.com/memcached/memcached/releases 官方wiki:https://github.com/memcached/memcached/wiki 启动参数: -p监听的端口 -l连接的IP地址,默认是本机 -dstart启动memcached服务 -drestart重起memcached服务 -dstop|sh 查看详情

配置lamp环境

对我这种Linux小菜鸡来说,集成环境是最好的选择。一,下载wget--no-check-certificatehttps://github.com/teddysun/lamp-yum/archive/master.zip-Olamp-yum.zip解压unziplamp-yum.zip赋权限cdlamp-yum-master/chmod+x*.sh二,下载集成环境./lamp.sh2>&a 查看详情

Laravel 的持续集成策略

】Laravel的持续集成策略【英文标题】:StrategyforContinuousIntegrationonLaravel【发布时间】:2016-12-1204:40:18【问题描述】:考虑以下场景:code-release.sh脚本接受一个随时可用的分支名称,该名称会被推送到BitBucket的git存储库。网络挂钩... 查看详情

sparkstreaming集成flume

1、安装flumeflume安装,解压后修改flume_env.sh配置文件,指定java_home即可。cphdfsjar包到flumelib目录下(否则无法抽取数据到hdfs上):$cp/opt/cdh-5.3.6/hadoop-2.5.0-cdh5.3.6/share/hadoop/hdfs/hadoop-hdfs-2.5.0-cdh5.3.6.jar/opt/cdh-5.3.6/flume 查看详情

2021-12-23fluttermodule源码方式集成流程分析

参考技术A官方文档将Fluttermodule集成到iOS项目https://flutter.cn/docs/development/add-to-app/ios/project-setup(1)这时候还没有App.framework,podspec文件是有了(2)有engine,Flutter.framework。(3)有插件列表podspecFlutterPluginRegistrant.podspec,这时没有... 查看详情