2021-07-20服务端

这篇博客详细介绍了如何从零开始学习SpringBoot和MySQL。首先,讲解了在IDEA中使用Maven创建SpringBoot工程,编写Controller并实现RESTful接口。接着,探讨了SpringBoot常用注解和MyBatis-Plus的使用,包括数据库连接和简单登录注册功能的实现。在MySQL部分,涵盖了数据库安装、常用字段、SQL操作以及各种JOIN查询方式。
摘要由CSDN通过智能技术生成

目录

1. springboot入门教程01

(1) 在idea中如何使用maven创建springboot工程

(2) 编写第一个controller

(3) restful接口如何编写

(4) springboot常用注解以及作用

(5) 如何使用mybaits-plus

(6) mybaits常用注解以及作用

(7) 编写一个简单的登陆注册功能

 2. mysql数据库

 (1) 数据库的安装

(2) 数据库常用字段

(3) 数据库与表的创建

(4) 增删查改的SQL格式

(5) IN 、BETWEEN 、LIKE 用法

(6) 关联查询

(7) INNER JOIN 、 LEFT JOIN 、RIGHT JOIN 、FULL JOIN  用法

 (8) 数据库常用函数


1. springboot入门教程01

(1) 在idea中如何使用maven创建springboot工程

新建project

 选择Maven 

确定路径和文件名 >>  Finish


(2) 编写第一个controller

pom.xml 注入依赖 ,application.yml 定义端口号

package test.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/test")
@ResponseBody
public class TestController {


    @GetMapping("/hello")
    public String hello(){return "Hello World";}

}


(3) restful接口如何编写

在启动类中加入下面方法

  @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

controller类加入注解

使用 url/doc.html 访问

localhost:8080/doc.html 

(4) springboot常用注解以及作用

 参考: SpringBoot常用注解以及作用


(5) 如何使用mybaits-plus

  • 引入依赖
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.1</version>
        </dependency>
  • 修改application.yml 
server:
  #服务器运行端口
  port: 8080

spring:
  datasource:
    #数据库链接url
    url: jdbc:mysql://*.*.*.*:25836/taobao?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
    #数据库账号密码
    username: root
    password: ******
    #数据库驱动类
    driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
  #mapper文件
  mapper-locations: classpath:mapper/*.xml
  configuration:
    map-underscore-to-camel-case: true
mybatis-plus:
  configuration:
    og-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志
  • 创建Mapper接口

        继承 BaseMapper 注解Mapper     


                
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值