开发模式和环境搭建

后台用到的知识

  • Validatation:参数校验
  • Mybatis:数据库的操作
  • Redis:缓存
  • Junit:单元测试
  • 项目部署

开发模式

使用接口文档对应路径和请求方式、请求参数、响应数据作详细说明。

环境搭建

  • 执行big_event.sql脚本
  • 准备数据库表 创建springboot工程,引入对应的依赖(web、mybatis、mysql驱动)
  • 配置文件application.yml中引入mybatis的配置信息 创建包结构,并准备实体类

 如何创建springboot工程?

新建项目

点击高级设置改一下名称

src文件夹下右键新建resources文件夹

 

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.1.3</version>
  </parent>

引入依赖

<!--  web依赖-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
<!--    mybatis依赖-->
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>3.0.0</version>
    </dependency>
<!--    mysql驱动依赖-->
    <dependency>
      <groupId>com.mysql</groupId>
      <artifactId>mysql-connector-j</artifactId>
    </dependency>

在application.yaml引入mybatis的配置文件

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/big_event
    username: root
    password: root123

创建包结构,准备实体类

在wxt文件夹下

controller:存放 controller类

service:在service接口下创建一个子包impl,实现service接口的实现类。

mapper:mapper接口

pojo:存放实体类

utils:存放工具类

把三个实体类放在pojo文件夹下

package com;


import java.time.LocalDateTime;

public class Article {
    private Integer id;//主键ID
    private String title;//文章标题
    private String content;//文章内容
    private String coverImg;//封面图像
    private String state;//发布状态 已发布|草稿
    private Integer categoryId;//文章分类id
    private Integer createUser;//创建人ID
    private LocalDateTime createTime;//创建时间
    private LocalDateTime updateTime;//更新时间
}
package com;

import java.time.LocalDateTime;

public class Category {
    private Integer id;//主键ID
    private String categoryName;//分类名称
    private String categoryAlias;//分类别名
    private Integer createUser;//创建人ID
    private LocalDateTime createTime;//创建时间
    private LocalDateTime updateTime;//更新时间
}
package com;



import java.time.LocalDateTime;

public class User {
    private Integer id;//主键ID
    private String username;//用户名
    private String password;//密码
    private String nickname;//昵称
    private String email;//邮箱
    private String userPic;//用户头像地址
    private LocalDateTime createTime;//创建时间
    private LocalDateTime updateTime;//更新时间
}

 

改造启动类

 

把App改为BigEventApplication 

然后报错了,提示我这个 

后来发现启动类写错了。。。。

 

 点击运行启动成功,该项目运行在本地的8080端口上了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值