1、数据库表设计java
SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for sys_permission -- ---------------------------- DROP TABLE IF EXISTS `sys_permission`; CREATE TABLE `sys_permission` ( `id` varchar(255) NOT NULL DEFAULT '', `description` varchar(255) NOT NULL DEFAULT '' COMMENT '权限描述', `name` varchar(255) NOT NULL DEFAULT '' COMMENT '权限名称', `pid` varchar(255) NOT NULL DEFAULT '' COMMENT '父节点', `url` varchar(255) NOT NULL DEFAULT '' COMMENT '受权连接', `create_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '建立时间', `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', `deleted` int(11) NOT NULL DEFAULT '0' COMMENT '删除标志位', `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', PRIMARY KEY (`id`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='权限表'; -- ---------------------------- -- Table structure for sys_role -- ---------------------------- DROP TABLE IF EXISTS `sys_role`; CREATE TABLE `sys_role` ( `id` varchar(255) NOT NULL DEFAULT '', `descprtion` varchar(255) DEFAULT '' COMMENT '角色描述', `name` varchar(255) DEFAULT '' COMMENT '角色名', `create_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '建立时间', `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', `deleted` int(11) NOT NULL DEFAULT '0' COMMENT '删除标志位', `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', PRIMARY KEY (`id`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='角色表'; -- ---------------------------- -- Table structure for sys_role_permission -- ---------------------------- DROP TABLE IF EXISTS `sys_role_permission`; CREATE TABLE `sys_role_permission` ( `permission_id` varchar(255) NOT NULL, `role_id` varchar(255) NOT NULL DEFAULT '', KEY `FKa6jx8n8xkesmjmv6jqug6bg68` (`role_id`), KEY `FKf8yllw1ecvwqy3ehyxawqa1qp` (`permission_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='角色权限关联表'; -- ---------------------------- -- Table structure for sys_uer_role -- ---------------------------- DROP TABLE IF EXISTS `sys_uer_role`; CREATE TABLE `sys_uer_role` ( `uid` varchar(255) NOT NULL, `role_id` varchar(255) NOT NULL DEFAULT '', KEY `FKdpira1rf7d4dg92yp4fg2ltij` (`role_id`), KEY `FKdb9d5h4r2iy9rld4fcvbdp7ab` (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='用户角色关联表'; -- ---------------------------- -- Table structure for sys_user_info -- ---------------------------- DROP TABLE IF EXISTS `sys_user_info`; CREATE TABLE `sys_user_info` ( `id` varchar(255) NOT NULL COMMENT '主键', `password` varchar(255) NOT NULL COMMENT '密码', `username` varchar(255) NOT NULL COMMENT '用户名', `age` int(11) NOT NULL COMMENT '年龄', `create_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '建立时间', `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', `email` varchar(255) NOT NULL COMMENT '邮箱', `phone` varchar(255) NOT NULL COMMENT '电话', `parent_id` varchar(255) NOT NULL COMMENT '上级', `deleted` int(11) NOT NULL DEFAULT '0' COMMENT '删除标志位', `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', PRIMARY KEY (`id`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='用户表'; SET FOREIGN_KEY_CHECKS = 1;
2、新建项目:初始化一个 Spring Boot 工程。mysql
一、添加依赖web
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.8.RELEASE</version> <relativePath/> </parent> <groupId>com.xiao</groupId> <artifactId>permission_system</artifactId> <version>0.0.1-SNAPSHOT</version> <name>permission_system</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.1.2</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.2.0</version> </dependency> <!-- Beetl 代码生成使用--> <dependency> <groupId>com.ibeetl</groupId> <artifactId>beetl</artifactId> <version>2.9.10</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-extension</artifactId> <version>3.2.0</version> <scope>compile</scope> </dependency> <!-- https://mvnrepository.com/artifact/io.swagger/swagger-annotations --> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> <version>1.5.20</version> </dependency> <dependency> <groupId>p6spy</groupId> <artifactId>p6spy</artifactId> <version>3.8.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
3、项目配置spring
#数据库配置 spring.datasource.url=jdbc:mysql://47.106.95.68:3306/permission_system?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false spring.datasource.username=root spring.datasource.password=000000 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver #spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver #spring.datasource.url=jdbc:p6spy:mysql://localhost:3306/permission_system #日志设置 logging.level.root = warn logging.level.com.xiao.permission_system.mapper = trace logging.pattern.console = %p%m%n #mapper.xml地址 mybatis-plus.mapper-locations = classpath*:/mapper/**/*.xml #全局设置主键类型 mybatis-plus.global-config.db-config.id-type = uuid #设置mybatis配置文件路径 spring.config.location = classpath:mybatis-config.xml #MyBaits 别名包扫描路径,经过该属性能够给包中的类注册别名,注册后在 Mapper 对应的 XML 文件中能够直接使用类名,而不用使用全限定的类名(即 XML 中调用的时候不用包含包名)。 mybatis-plus.type-aliases-package = com.xiao.permission_system.entity #逻辑删除状态设置 mybatis-plus.global-config.db-config.logic-not-delete-value = 0 mybatis-plus.global-config.db-config.logic-delete-value= = 1 server.port=8088 #自定义用户名和密码 #spring.security.user.name=admin #spring.security.user.password=000000
4、项目文件结构设计 sql
5、代码生成 http://www.javashuo.com/article/p-mupqrllf-na.html数据库