适合springboot2初学者
学了springboot2知识,就要用起来,不敲代码的程序员不是好程序员。笔者参考了他人的文章实现的这个功能,在自己的搭建过程中也遇到了许多问题,并花了一定的时间解决,下面开始吧!
一、登录注册第一步
首先,实现登录注册,我们是不是要先定义一个表?表里面要有什么,看看自己的需求。下面是笔者的数据库表,创建一个名为demo
的数据库,里面建立一个user
用户表,并有如图字段,我先记录了一些信息可忽略:
二、
搭建springboot项目
笔者是从maven项目开始搭建的,然后手打成springboot项目,其实二者区别就是依赖的建立问题,maven项目的依赖是空的,springboot在创建的过程中有勾选的选项,就不用手动输入依赖了。创建一个简单的springboot项目相信各位都会,不行就找其他的博客看看。创建完成后,
1.在pom.xml文件中导入依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.experimental</groupId>
<artifactId>spring-native</artifactId>
<version>${spring-native.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>