LEEYANGY

LEEYANGY 关注TA

拼搏百天,我要上湖工大!

LEEYANGY

LEEYANGY

关注TA

拼搏百天,我要上湖工大!

  •  Wuhan/HuBei
  • 学生
  • 写了322,476字

该文章投稿至Nemo社区   Java  板块 复制链接


springcloud课程设计

发布于 2023/04/26 13:52 5,830浏览 1回复 12,126

选题 xxx校园系统设计实现,

spring 6 mybatisplus踩坑(末尾)

目前正在做的功能:

优化权限和前端动态路由;课表和成绩来源,由于无法正规获取,目前打算通过使用爬虫获取。。。

前端路由和组件也需要优化,之前赶时间交任务,所有做的有些粗糙,近期会按规范整理

班级信息如果不考虑做 签到 这个模块的话,班级功能暂时不做

目前以完成部分功能开发

大概有两个分支,一个分支是继续基于springboot的单体开发,另一分支是将该项目拆分成微服务设计模式,也就是课程设计的要求

单体项目,着重点在于修复权限,采用rbac权限设计模式,对于聊天功能进行深入开发和研究其技术,尽量会加上多线程,以达到自己的学习目的

springcloud基于spring cloud alibaba 进行开发,能做成啥样,未知,哈哈哈哈。

搭建父子项目

首先新建一个工作空间

需要明确一点是,父项目只用来版本锁定,子项目按需引入依赖

依赖版本锁定


需要将图中的jar,改为pom


下面两段是需要的依赖

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<springboot.version>2.7.10</springboot.version>
<mybatis.version>2.1.1</mybatis.version>
<lombok.version>1.18.10</lombok.version>
<junit.version>4.12</junit.version>
<mysql.version>8.0.32</mysql.version>
<mybatiplus.version>3.4.1</mybatiplus.version>
<jjwt.version>0.9.1</jjwt.version>
<fastjson.version>1.2.83</fastjson.version>
<hutools.version>5.8.11</hutools.version>
<lombok.version>1.18.26</lombok.version>
<apache.commons.version>3.5</apache.commons.version>
<velocity-engine-core.version>2.2</velocity-engine-core.version>
<!-- <maven.test.skip>true</maven.test.skip>-->
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${springboot.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${springboot.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${springboot.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${springboot.version}</version>
<!-- 防止将依赖传递到其他模块中 -->
<optional>true</optional>
<!-- 只在运行时起作用,打包时不打进去(防止线上执行打包后的程序,启动文件监听线程File Watcher,耗费大量的内存资源) -->
<scope>runtime</scope>
</dependency>

<!--引入druid spring boot自带的数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.8</version>
</dependency>
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
<!-- <scope>runtime</scope>-->
</dependency>
<!--mp-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
</dependency>
<!-- 添加 模板引擎 依赖 -->
<!--mp代码生成器-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${mybatiplus.version}</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>${velocity-engine-core.version}</version>
</dependency>
<!-- <!–mp代码生成器依赖freemarker模板渲染引擎–>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-freemarker</artifactId>-->
<!-- </dependency>-->

<!--jwt-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
</dependency>

<!--fastJson-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>

<!--huTool-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutools.version}</version>
</dependency>

<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>

<!-- spring security 安全认证 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${springboot.version}</version>
</dependency>

<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>${springboot.version}</version>
</dependency>

<!-- thymeleaf模板引擎-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>${springboot.version}</version>
</dependency>

<!-- log4j-->
<!-- <dependency>-->
<!-- <groupId></groupId>-->
<!-- <artifactId>log4j</artifactId>-->
<!-- </dependency>-->

<!-- apache commons-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache.commons.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

在父目录下新建子项目

再建一个子项目

直接引入子项目common-api即可


改造core-system的启动器并编写控制器代码进行测试

@RestController
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class,args);
}

@GetMapping("/test")
public String index(){
return "test success";
}

配置数据库后,通过浏览器访问ip:port,看到响应的数据即是正常

其它地方基本相似,一个建议的父子项目搭建完毕



近期贴出

数据库er

 写了快一半了,感觉自己建的表有一丢丢奇怪

整体:


部分:









我的代码


接口汇总

获取动态: 

获取最大记录数: method: GET /system/zone/getMaxTotal

分页查询: method: GET params: Integer page 页码 Integer limit 页面容量 /system/zone/getAllArticle/{page}/{limit}

动态详细: method: GET params: Long id 动态的id /system/zone/getDetail/{id}

通过动态id删除动态

method: DELETE /system/zone/delZone/{id}

查询用户动态记录

method: GET

params: Long userId 用户id

/system/zone/getUserMaxTotal/{userId}
分页查询用户的动态记录 method: GET paarams: Long userId 用户id Integer page 页码 Integer limit 页面容量

/system/zone/getMyArticle/{userId}/{page}/{limit}

这里服用了接口,在请求的时候进行id判断如果查不到数据,就做为添加

method: POST params: Zone.class /system/zone/editZone 请求表单:

自助申请
method: POST
params:Event.class

/system/event/cafeAdd


查询用户的申请记录数
method: GET
params: Long sponsor_id   发布人的id也就是用户id

/system/event/getTotal/{sponsor_id}

分页查询,查询指定用户的数据

method: GET

params:

        Long sponsor_id 发布人的id通userId

        Integer page 页码

        Integer limit 页面容量

/system/event//getMyCafeRecord/{sponsor_id}/{page}/{limit}

更新用户的申请 method: PUT params : Event.class /system/event/updateRecord
获取用户的申请信息 method: GET params: Long id 申请记录的id /system/event/getMyCafeDetailRecord/{id}
校园专区:

获取所有聊天记录: method: GET params: Long gid 群组id /system/zone/getChatContent/{gid}

ws连接: params: String username 用户名 /imserver/{username}

查看在线人数: params: String username 用户名 /imserver/{username} 消息: 获取所有消息 method: GET

/system/message/getAllMessage

用户信息维护

登录: method: POST /system/user/login

登出: method: GET /system/user/logout 用户信息修改: method: PUT params: User.class /system/user/putUserInfo 获取指定用户信息 method: GET params: Long userId 用户id /system/user/getUserInfo/{userId} 权限测试接口:

/hello

/hello/vip1


以下是idea生成的

###
GET http://localhost:18888/system/zone/getAllArticle/{{page}}/{{limit}}

###
GET http://localhost:18888/system/zone/getMaxTotal

###
GET http://localhost:18888/system/zone/getUserMaxTotal/{{userId}}

###
GET http://localhost:18888/system/zone/getMyArticle/{{userId}}/{{page}}/{{limit}}

###
GET http://localhost:18888/system/zone/getDetail/{{id}}

###
POST http://localhost:18888/system/zone/editZone

###
DELETE http://localhost:18888/system/zone/delZone/{{id}}

###
POST http://localhost:18888/system/event/cafeAdd

###
GET http://localhost:18888/system/event/getTotal/{{sponsor_id}}

###
GET http://localhost:18888/system/event/getMyCafeRecord/{{sponsor_id}}/{{page}}/{{limit}}

###
GET http://localhost:18888/system/event/getMyCafeDetailRecord/{{id}}

###
PUT http://localhost:18888/system/event/updateRecord

###
POST http://localhost:18888/system/user/login

###
GET http://localhost:18888/system/user/logout

###
GET http://localhost:18888/system/user/getUserInfo/{{userId}}

###
PUT http://localhost:18888/system/user/putUserInfo

###
GET http://localhost:18888/hello

###
GET http://localhost:18888/hello/vip1



项目部分截图:

如需体验项目部分功能,请前往 在线演示地址

更多功能在完善中

前后端都采用docker方式部署在服务器中运行

前后端分离,前端vue3(vite4)+vant4ui组件,后端 springboot 2.7.10,暂时用spring单体框架,6月份拆分成springcloud项目


校园首页


核心功能(自助审批,请假,)



用户中心


非核心模块之聊天社交(使用了websocket之后,权限校验好像时效,待项目整体完成之后,再寻找解决方案)

数据从数据库加载



Springboot 版本 3.1.0

<!--mp-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
</dependency>
<!-- 我加了这段就不报错了-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.1</version>
</dependency>


MP 报错解决

Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
springboot 3版本整合 mybatis 3.0.5版本控制台报错 Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required,NestedIOException 这个类在 Spring 6 版本中直接删除了。而 MyBatis 老版本还没有同步更新,所以直接就报红了。而整合 mybatis 的 mybatis-plus 自然也会报红。


点赞(0)
点了个评