基于Spring Boot +Mysql 的后台管理系统——实现简单的用户登录

Spring Boot是一个基于Java的开源框架,用于创建微服务。它由Pivotal Team开发,用于构建独立的生产就绪Spring应用。

Spring Boot为Java开发人员提供了一个很好的平台,可以开发一个可以运行的独立和生产级Spring应用程序。可以开始使用最少的配置,而无需进行整个Spring配置设置。

优点:

Spring Boot为其开发人员提供以下优势 -

  • 易于理解和开发Spring应用
  • 提高生产力
  • 缩短开发时间

目标:

Spring Boot的设计目标如下

  • 避免在Spring中进行复杂的XML配置
  • 以更简单的方式开发生产就绪的Spring应用程序
  • 减少开发时间并独立运行应用程序
  • 提供一种更简单的应用程序入门方式

数据库表(users)设计:

 

 

用户登录实现:

一、创建一个maven项目。

我的工作项目目录如下:

二、在pom.xml配置文件中引入相关的组件

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jdbc</artifactId>
        </dependency>

     <dependency>
            <groupId>io.mybatis</groupId>
            <artifactId>mybatis-mapper</artifactId>
            <version>1.2.2</version>
        </dependency>

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.1</version>
        </dependency>

     <!-- mybatis-spring-boot-starter -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </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>

三、、在application.properties 配置文件中,配置连接数据库的数据源,配置服务器端口、配置文件上传相关配置

和启用Rest。

#配置服务器端口
server.port=8080

#启用 Rest
spring.mvc.hiddenmethod.filter.enabled=true

#禁用 thymeleaf 缓存
spring.thymeleaf.cache=false


#配置文件上传相关配置
spring.servlet.multipart.max-file-size=5MB
spring.servlet.multipart.max-request-size=50MB


#数据源配置
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/lease?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=


#配置连接池
spring.datasource.druid.initial-size=2
spring.datasource.druid.max-active=5

 创建users接口:UserDao.java。设置selectUser方法,把查询到的数据库信息返回控制层

package cn.gxks.web.leasemall.dao.fron;

import cn.gxks.web.leasemall.enti
  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值