毕业设计——基于ssm+shiro+redis+nginx tomcat服务器集群管理项目
完整项目地址:https://download.csdn.net/download/lijunhcn/88430549
1.搭建一个最简洁,模块划分最明确的ssm+swargger+shiro+redis+nginx整合项目,采用maven作为构建工具,在有新项目开发时可以借助此demo快速构建项目
2.实现shiro的授权信息缓存到redis数据库,减少关系数据库访问压力
3.实现session共享到redis,实现多服务器集群方案
4.配置文档中包含丰富的注释,搭建思路清晰的ssm项目框架
5.项目中的所有细节都会按照企业级开发的标准,展示如何遵循代码规范以及类文件doc注释的编写。
6.采用RESTFul的controller接口,展示RESTFul风格的API编写(shiro基于url的权限拦截与RESTFul API兼容性不好,后期可能会改写shiro以匹配RESTFul)
7.Junit单元测试,展示如何正确的使用Junit单元测试验证自己接口代码的健壮性
涉及到的技术
springmvc+spring+mybatis:轻量级敏捷开发框架
swargger:快速构建RestFul接口测试页面
shiro:Apache开源权限管理框架,包括登录验证,授权,加密,会话管理
redis:Nosql数据库,搭配shiro的会话管理功能将session存入redis中,实现tomcat多服务器集群的session共享
nginx:反向代理服务器,用来调度多台tomcat
h2:内存数据库,用于测试
开发环境
jdk1.8+mysql5.7.22+tomcat8.5.32+IDEA
项目部署
第一次部署项目
1.修改ssm-rs\resources目录下db.properties的数据库账号密码信息
2.启动redis服务端,修改ssm-rs\resources\spring-config目录下spring-shiro.xml中redis的连接信息,没设置密码的话auth留空
2.创建数据库train_db并执行根目录下的train_db.sql数据库脚本
3.进入到ssm-build目录下,执行clean install -Dmaven.test.skip=true,对整个项目进行构建
4.启动ssm-rs项目,浏览器访问http://localhost/ssm-rs/swagger-ui.html
项目模块
ssm-build
项目聚合模块,可以进入该项目目录,对整个项目进行构建。
mvn clean install -Dmaven.test.skip=true
ssm-parent
父模块,其他模块会继承该模块,引入公共的依赖
ssm-model
模型层模块,提供各种POJO。包括与数据库表对应的模型、传输模型等。提供给service层(ssm-cs)、controller层(ssm-rs)。
ssm-commons
包含各种工具类
ssm-cs
service层和dao层,提供具体的业务逻辑和数据库访问,需要依赖ssm-model模块,并提供出来给ssm-rs模块调用
ssm-rs
controller层,提供RESTFul接口。文章来源:https://www.toymoban.com/news/detail-762426.html
项目SQL部分源码文章来源地址https://www.toymoban.com/news/detail-762426.html
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50722
Source Host : localhost:3306
Source Database : train_db
Target Server Type : MYSQL
Target Server Version : 50722
File Encoding : 65001
Date: 2018-07-27 15:17:28
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for tra_permissiontype
-- ----------------------------
DROP TABLE IF EXISTS `tra_permissiontype`;
CREATE TABLE `tra_permissiontype` (
`permissonType_id` bigint(20) NOT NULL AUTO_INCREMENT,
`permissionType_name` varchar(255) NOT NULL,
KEY `permissonType_id` (`permissonType_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tra_permissiontype
-- ----------------------------
INSERT INTO `tra_permissiontype` VALUES ('1', '奖品管理');
-- ----------------------------
-- Table structure for tra_permission
-- ----------------------------
DROP TABLE IF EXISTS `tra_permission`;
CREATE TABLE `tra_permission` (
`permission_id` bigint(20) NOT NULL AUTO_INCREMENT,
`permission_name` varchar(255) NOT NULL,
`perimission_url` varchar(255) NOT NULL,
`permissioon_type` bigint(20) NOT NULL,
PRIMARY KEY (`permission_id`),
KEY `FK_permissionType` (`permissioon_type`),
CONSTRAINT `FK_permissionType` FOREIGN KEY (`permissioon_type`) REFERENCES `tra_permissiontype` (`permissonType_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tra_permission
-- ----------------------------
INSERT INTO `tra_permission` VALUES ('1', 'prize:add', '/v1.0/prize/add', '1');
INSERT INTO `tra_permission` VALUES ('2', 'prize:delete', '/v1.0/prize/delete/*', '1');
INSERT INTO `tra_permission` VALUES ('3', 'prize:update', '/v1.0/prize/update/*', '1');
INSERT INTO `tra_permission` VALUES ('4', 'prize:get', '/v1.0/prize/get/*', '1');
-- ----------------------------
-- Table structure for tra_prizes
-- ----------------------------
DROP TABLE IF EXISTS `tra_prizes`;
CREATE TABLE `tra_prizes` (
`prize_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '唯一表识',
`prize_name` varchar(50) NOT NULL COMMENT '奖品名称',
`created_time` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`prize_id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Records of tra_prizes
-- ----------------------------
INSERT INTO `tra_prizes` VALUES ('15', 'string', '2018-07-26 11:49:10');
INSERT INTO `tra_prizes` VALUES ('16', 'string', '2018-07-26 12:00:43');
INSERT INTO `tra_prizes` VALUES ('17', 'string', '2018-07-26 12:01:55');
INSERT INTO `tra_prizes` VALUES ('18', 'string', '2018-07-26 12:03:16');
INSERT INTO `tra_prizes` VALUES ('19', 'string', '2018-07-26 17:25:47');
INSERT INTO `tra_prizes` VALUES ('20', 'string', '2018-07-26 17:27:47');
INSERT INTO `tra_prizes` VALUES ('21', 'string', '2018-07-26 17:31:54');
INSERT INTO `tra_prizes` VALUES ('22', 'string', '2018-07-26 17:54:20');
INSERT INTO `tra_prizes` VALUES ('23', 'string', '2018-07-27 08:46:05');
INSERT INTO `tra_prizes` VALUES ('24', 'string', '2018-07-27 09:00:45');
INSERT INTO `tra_prizes` VALUES ('25', 'string', '2018-07-27 11:06:17');
INSERT INTO `tra_prizes` VALUES ('26', 'string', '2018-07-27 14:45:56');
INSERT INTO `tra_prizes` VALUES ('27', 'string', '2018-07-27 14:54:25');
INSERT INTO `tra_prizes` VALUES ('28', 'string', '2018-07-27 14:55:07');
INSERT INTO `tra_prizes` VALUES ('29', 'string', '2018-07-27 14:56:29');
INSERT INTO `tra_prizes` VALUES ('30', 'string', '2018-07-27 14:58:23');
INSERT INTO `tra_prizes` VALUES ('31', 'string', '2018-07-27 15:05:13');
-- ----------------------------
-- Table structure for tra_role
-- ----------------------------
DROP TABLE IF EXISTS `tra_role`;
CREATE TABLE `tra_role` (
`role_id` bigint(20) NOT NULL AUTO_INCREMENT,
`role_name` varchar(255) NOT NULL,
PRIMARY KEY (`role_id`),
UNIQUE KEY `uniq_rolename` (`role_name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tra_role
-- ----------------------------
INSERT INTO `tra_role` VALUES ('1', 'admin');
-- ----------------------------
-- Table structure for tra_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `tra_role_permission`;
CREATE TABLE `tra_role_permission` (
`role_permission_id` bigint(20) NOT NULL AUTO_INCREMENT,
`role_id` bigint(20) NOT NULL,
`permission_id` bigint(20) NOT NULL,
PRIMARY KEY (`role_permission_id`),
UNIQUE KEY `uniq_roleId_permissionId` (`role_id`,`permission_id`) USING BTREE,
KEY `FK_permission_id` (`permission_id`),
CONSTRAINT `FK_permission_id` FOREIGN KEY (`permission_id`) REFERENCES `tra_permission` (`permission_id`),
CONSTRAINT `FK_role_ids` FOREIGN KEY (`role_id`) REFERENCES `tra_role` (`role_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tra_role_permission
-- ----------------------------
INSERT INTO `tra_role_permission` VALUES ('1', '1', '1');
-- ----------------------------
-- Table structure for tra_user
-- ----------------------------
DROP TABLE IF EXISTS `tra_user`;
CREATE TABLE `tra_user` (
`user_id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) NOT NULL,
`user_password` varchar(15) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `uniq_username` (`user_name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tra_user
-- ----------------------------
INSERT INTO `tra_user` VALUES ('1', 'liuruojing', '123456');
-- ----------------------------
-- Table structure for tra_user_role
-- ----------------------------
DROP TABLE IF EXISTS `tra_user_role`;
CREATE TABLE `tra_user_role` (
`user_role_id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`role_id` bigint(20) NOT NULL,
PRIMARY KEY (`user_role_id`),
UNIQUE KEY `uniq_userId_roleId` (`user_id`,`role_id`) USING BTREE,
KEY `FK_user_id` (`user_id`) USING BTREE,
KEY `FK_role_id` (`role_id`),
CONSTRAINT `FK_role_id` FOREIGN KEY (`role_id`) REFERENCES `tra_role` (`role_id`),
CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `tra_user` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tra_user_role
-- ----------------------------
INSERT INTO `tra_user_role` VALUES ('1', '1', '1');
到了这里,关于毕业设计——基于ssm+shiro+redis+nginx tomcat服务器集群管理项目的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!