基于RESTful风格搭建后台CRUD服务
具体技术为SpringBoot + JDBC API,编译工具IntelliJ IDEA 2021.1.3 (Ultimate Edition),JDK版本为1.8.0
1. 框架结构准备
1.1 搭建项目
项目搭建参考 https://blog.csdn.net/baekhyunee_05/article/details/120343069
1.2 建立相关数据库表以及插入数据
1.3 相关依赖
IDEA版本和JDK版本会导致依赖的版本不同,如有报错请自己重新导入各项适合自己版本的依赖包。
pom.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>RestDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RestDemo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>