SpringBoot
秃顶少女
一个即将秃顶的少女
展开
-
SpringBoot-日志
配置日志输出文件路径#日志打印路径logging.file.path=logs/community.loglogging.level.root=infologging.level.com.july.community.mapper=debuglogging.file.max-history=30实现打印日志@Slf4jclass ...{...log.error("...原创 2020-02-22 22:51:36 · 194 阅读 · 1 评论 -
SpringBoot-实现搜索功能
构造一个对象QuestionQueryDTOpackage com.july.community.dto;import lombok.Data;@Datapublic class QuestionQueryDTO { private String search; private Integer page; private Integer size;}...原创 2020-02-22 22:19:31 · 9524 阅读 · 5 评论 -
SpringBoot-实现图片上传 | 阿里云OSS
准备工作准备一个云主机。云主机不一定要使用阿里云,只是最近疫情期间,阿里云有活动,学生可以免费用6个月,我今早定了闹钟7点50就起来抢这个免费的云主机了开通OSS使用OSS教程文件创建bucket编码部分java中实现上传的教程参考:https://help.aliyun.com/document_detail/32013.html?spm=a2c4g.1118662...原创 2020-02-22 18:20:28 · 960 阅读 · 13 评论 -
SpringBoot-实现回复通知的功能
发出信息的实现创建信息数据库create table tbl_message( id bigint auto_increment, notifier bigint not null comment '发出消息的人', receiver bigint not null comment '接收消息的人', outerId bigint not null comment '信息所对应的...原创 2020-02-19 22:39:04 · 2496 阅读 · 4 评论 -
SpringBoot-规范标签库
定义TagDTO对象package com.july.community.dto;import lombok.Data;import java.util.List;@Datapublic class TagDTO { private String categoryName; //分类 private List<String> tagList;}...原创 2020-02-19 17:28:12 · 454 阅读 · 0 评论 -
SpringBoot-实现社区中相关问题的展示
当查看问题详情的时候,展示含有相同标签的问题为相关问题后端逻辑使用正则来查询符合条件的数据。在QuestionExtMapper中添加方法List<Question> selectRelated(Question record);<select id="selectRelated" parameterType="com.july.community.model.Qu...原创 2020-02-19 00:14:22 · 139 阅读 · 0 评论 -
SpringBoot-对评论进行回复:js动态绘制前端
实现发出子评论此处发出post请求进行评论的回复与回复问题逻辑差不多,因此修改相关代码,进行复用重构js方法/** * 实现评论的功能 */function comment(e) { var type = e.getAttribute("data-type");//获取回复类型 //根据回复类型的不同获取父id if (type == 1){ ...原创 2020-02-18 18:39:00 · 779 阅读 · 2 评论 -
SpringBoot-实现回复列表显示的功能
前端代码htmlcss后端逻辑创建CommentDTO注:之前为了接受页面戳过来的关于comment的值,已经创建了一个,将旧的名字改为CommentCreateDTOpackage com.july.community.dto;import com.july.community.model.User;import lombok.Data;@Datapu...原创 2020-02-17 17:41:08 · 1203 阅读 · 0 评论 -
SpringBoot-实现评论功能(事务)
实现评论功能数据库的构建创建评论数据表create table tbl_comment( id bigint auto_increment, parent_id bigint not null comment '父类id,父类可能是question,也可以同样是comment', type int not null comment '父类的类型,是问题或者评论', commen...原创 2020-02-16 22:45:43 · 5627 阅读 · 4 评论 -
SpringBoot-实现阅读数的增加功能(考虑并发)
考虑多用户同时访问的情况。先创建一个自己的mapper配置文件xmlQuestionExtMapper.xml<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis...原创 2020-02-16 12:55:41 · 1553 阅读 · 2 评论 -
SpringBoot-通用异常处理
使用ControlerAdvice和ExceptionHandler实现对异常的处理,使用户使用感更好。编写错误显示页面error.html<!DOCTYPE HTML><html xmlns:th="http://www.thymeleaf.org"><head> <title>SpringBoot-社区</title&g...原创 2020-02-15 21:28:51 · 235 阅读 · 0 评论 -
SpringBoot-集成Mybatis Generator
Mybatis 与 Mybatis Generator区别MyBatis:一种操作数据库的框架,提供一种Mapper类,支持让你用java代码进行增删改查的数据库操作,省去了每次都要手写sql语句的麻烦。但是,你得先在xml中写好sql语句Mybatis Generator:自动为Mybatis生成简单的增删改查sql语句的工具,省时间Mybatis Plus:国人团队苞米豆在Mybati...原创 2020-02-15 17:48:41 · 221 阅读 · 0 评论 -
SpringBoot-拦截器
许多页面刚加载时需要验证用户是否登录,于是会出现大量的重复的登录校验的代码。此时可以使用Spring的拦截器技术。编写拦截配置类package com.july.community.interceptor;@Configurationpublic class WebConfig implements WebMvcConfigurer { @Override pub...原创 2020-02-12 20:06:12 · 176 阅读 · 0 评论 -
SpringBoot-社区项目-完成发布问题页面的功能
发布问题页面如下:实现发布功能创建数据表tbl_questioncreate table tbl_question( id int auto_increment, title varchar(50) null, description text null, time_create bigint null, time_modified bigint null, creato...原创 2020-02-11 14:27:49 · 424 阅读 · 0 评论 -
SpringBoot-集成Flyway Migration
Flyway 是数据库的版本控制管理工具。当一个团队中,有人对数据库做出了修改,可以同步给团队中的所有人,团队中所有成员的数据库都会得到相应的改动。引入依赖<!-- FlyWay--> <dependency> <groupId>org.flywaydb</groupId> &...原创 2020-02-10 14:06:41 · 473 阅读 · 0 评论 -
SpringBoot-实现持久化登录状态获取
编写登录的controller文件写入cookie//登陆成功后//...将用户账号信息存入数据库中//写cookie,(因存入数据库,无需写入session了) response.addCookie(new Cookie("token",token));...原创 2020-02-09 23:38:19 · 4928 阅读 · 1 评论 -
SpringBoot-整合Mybatis
加入依赖<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.1</version></...原创 2020-02-09 20:52:24 · 243 阅读 · 0 评论 -
SpringBoot-H2数据库
引入h2数据库的依赖<!-- H2数据库--> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1....原创 2020-02-09 00:57:04 · 211 阅读 · 0 评论 -
登录功能-Cookie&Session
Cookie&Session小匠老师的比喻:Session像是在银行中开的一个账户,银行的数据库会存有你账户的相关信息;Cookie像是银行卡,只有你带上银行卡去才能够读出你账户的信息。登录后接上一讲:使用GitHub授权进行登录修改AuthorizeController类/** * 登录后回调 */@Controllerpublic class Authoriz...原创 2020-02-07 17:08:36 · 404 阅读 · 0 评论 -
SpringBoot-实现GitHub授权登录的方式
注册GitHub的App账号在GitHub的个人页面中进行如下操作:settings-》Developer Settings-》OAuth Apps填写信息,如下图提交。跳转后,在页面填写信息如下(设置应用logo)参考GitHub相关文档:https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-...原创 2020-02-06 23:20:21 · 1194 阅读 · 6 评论 -
Git中仓库使用SSH的方式
GIT克隆项目使用SSH方式不需要每一次都登录,下面介绍给仓库配置SSH密码的方式。生成key在你需要的文件路径下打开Git Bash指令:$ ssh-keygen -t rsa -b 4096 -C “your_email@example.com”一直点击回车运行指令:clip < ~/.ssh/id_rsa.pub若没有提示,则为运行成功回到个人页面:https://gi...原创 2020-02-05 22:15:57 · 700 阅读 · 0 评论 -
SpringBoot-HelloWorld示例
准备工作jdk1.8mavenidea/eclipse/stsspringBoot 1.5.6HelloWorld示例说明:web应用。浏览器发送hello请求,服务器接受清收并进行处理。之后响应hello world字符串。1.创建maven工程2.导入springBoot相关依赖编写pom.xml文件父级依赖<parent><groupId&g...原创 2019-08-25 18:15:20 · 696 阅读 · 0 评论