当前位置: 首页 > article >正文

开发模式和环境搭建

后台用到的知识

  • 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端口上了


http://www.kler.cn/news/303024.html

相关文章:

  • Android 开发避坑经验第三篇:RecyclerView 高效使用与常见问题解决
  • centos下nvme over rdma 环境配置
  • vue原理分析(十二)研究new Vue()中的 initInjections
  • MVVM 基础
  • 计算机科学基础 -- 超流水线
  • cross-plateform 跨平台应用程序-04-React Native 介绍
  • 缓存预热/雪崩/穿透/击穿
  • 基于Python实现一个庆祝中秋节的小程序
  • C#笔记7 网络通信抽象,Socket类的介绍和简单使用
  • 逆向工程 反编译 C# net core
  • 布偶猫应该喂什么猫罐头:交响乐金罐、希喂、尾巴生活测评
  • 复现PointNext代码
  • 【Qt笔记】QGroupBox控件详解
  • 搭建一个大模型API服务
  • 代码随想录打卡Day29
  • 安宝特案例 | AR如何大幅提升IC封装厂检测效率?
  • C++20标准对线程库的改进:更安全、更高效的并发编程
  • 基于SpringBoot+Vue的民宿管理系统
  • pip install “git+https://xxx“报错error: subprocess-exited-with-error
  • Rust:深入浅出说一说 Error 类型
  • Oracle数据库中的Oracle Real Application Clusters是什么
  • SpringBoot动态SQL
  • 第15-02章:理解Class类并获取Class实例
  • leetcode1.两数之和
  • 编写XBOX控制器实现鼠标键盘输入
  • Python | Leetcode Python题解之第400题第N位数字
  • Iceberg与SparkSQL写操作整合
  • 【IP协议】IP协议报头结构(上)
  • Entity Framework (EF)框架中三种主要的数据加载策略
  • 反序列化漏洞练习1