1、用IDEA启动ruoyi项目
2、在mysql打开数据库ry,新建表学生表tb_student,表结构如下
3、运行ruoyi,在系统工具-代码生成 中导入新建表tb_student
4、修改生成配置
5、在菜单管理下新增学生管理目录
6、生成代码
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生管理', '2000', '1', '/student/student', 'C', '0', 'student:student:view', '#', 'admin', sysdate(), '', null, '学生管理菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生管理查询', @parentId, '1', '#', 'F', '0', 'student:student:list', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生管理新增', @parentId, '2', '#', 'F', '0', 'student:student:add', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生管理修改', @parentId, '3', '#', 'F', '0', 'student:student:edit', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生管理删除', @parentId, '4', '#', 'F', '0', 'student:student:remove', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('学生管理导出', @parentId, '5', '#', 'F', '0', 'student:student:export', '#', 'admin', sysdate(), '', null, '');
7、在IDEA项目中,新建模块ruoyi-student,将生成的代码拷贝到项目模块ruoyi-student的目录如下,
将controller下的文件studentController.java,拷贝到如下目录:
注意:将此controller文件放到ruoyi-admin模块下,是为了保持项目模块化清晰条理,ruoyi-admin模块为后端与前端交互文件存放目录。
8,在各模块pom文件中引入依赖
9、运行ruoyi项目
业务模块访问出现404
1、单应用检查
-
确认此用户是否已经配置菜单
-
确认此角色是否已经配置菜单权限
-
确认此菜单url是否和后台代码一致
如参数管理 后台配置@RequestMapping("/system/config")对应参数管理url为/system/config
2、多模块检查(多了几个步骤)
-
pom.xml 引入了业务子系统
-
ruoyi-admin 添加业务子模块的依赖
-
ruoyi-xxxxx 新增业务模块pom检查配置是否正确
PS:IDEA可能存在缓存,需要清理下缓存在编译。