Giter VIP home page Giter VIP logo

got's People

Contributors

bluesmilee avatar cookieshi2333 avatar fish-pop avatar lfc360421 avatar seltongithub avatar xilpikachu avatar

Watchers

 avatar

got's Issues

chapter3-1-3 日志处理 整合log4j2

问题描述

项目推进中,如果说第一件事是搭Spring框架的话,那么第二件事情就是在Sring基础上搭建日志框架,尤其是线上Web项目,因为日志可能是我们了解应用如何执行的唯一方式,这一了解过程尤其在线上项目出现bug时更加重要.

帮助文档

问题维护

如何发现了任何觉得有帮助理解和练习等的文档,可以在下方评论

chapter3-1-1 构建一个较为复杂的RESTful API

在上个任务 #2 的代码基础上 完成以下

使用postman工具模拟http请求

  1. 添加用户
  • 请求方法 post
  • 请求url localhost:8080/user/add
  • 请求体 {"name":"xiaolin", "age": 21}
  • 返回结果 ok

  1. 查询用户
  • 请求方法 get
  • 请求url localhost:8080/user/1
  • 返回结果 {"id": 1, "name":"xiaolin", "age": 21}

  1. 修改用户
  • 请求方法 put
  • 请求url localhost:8080/user/1
  • 请求体 {"id": 1, "name":"xiaolin2", "age": 22}
  • 返回结果 1
  1. 删除用户
  • 请求方法 put
  • 请求url localhost:8080/user/1
  • 请求体 {"id": 1, "name":"xiaolin2", "age": 22}
  • 返回结果 1

提示: 不用使用数据库 使用类似static的Map或者List临时存储就可以 顺带熟悉一下postman的使用 不用写前端页面了

chapter3-1-2 统一异常处理

使用postman工具模拟http请求

模拟在controller中抛出异常(比如直接在controller中throw一个异常) 然后使用springboot的统一异常捕获 将其捕获 并且封装成固定格式的json返回

提示: 我们不应该在每个controller中写入try catch 来封装异常, springboot有实现了类似java的叫做动态代理的名为aop的切面处理, 关键字 advice.

例: http get请求访问localhost:8080/user/2
controller中抛出了某种异常 程序返回结果为 {"status": 500, "data": "a exception occur"}
如果controller没有抛出异常 程序返回结果为 {"status": 200, "data": {"id": 2, "name":"xiaolin", "age": 21}}

chapter3-1-4 提取业务逻辑

问题描述

controller主要完成的是路由的功能,在controller中写入诸多代码显然是不合理的,使用@ Service注解的Service实现类将业务逻辑代码从controller中提取出来

帮助文档

注意: 更进一步: 1. 使用 @ Service 注解,也就是使用spring提供的依赖注入 2.完全的剥离

git分支拆分与重构当前项目

为什么选择多分支

任务背景

git必杀技--分支-廖雪峰

任务过程描述

本地将原本在主分支master上的代表各个组的文件夹分别拆分到了名称为文件夹名称的分支中
在小组对应的分支中的内容 就是以前小组文件夹内的内容

问题和反馈

有问题和有建议等一切问题可以随时评论

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.