SpringBoot入门小项目 springboot+mybatis+mysql+thymeleaf实现数据库操作并展示数据

1. springboot的demo项目快速部署下载

官方demo项目快速部署

2. MySQL安装下载

此处不做描述

3. 代码

3.1 依赖

dependencies {
   
	compile('org.springframework.boot:spring-boot-starter-web')
	testCompile('org.springframework.boot:spring-boot-starter-test')
	compile('org.springframework.boot:spring-boot-starter')
	
	compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1')
	compile('mysql:mysql-connector-java')
	compile 'net.sourceforge.nekohtml:nekohtml:1.9.12'
	compile 'org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE'
}

mybatis依赖+mysql数据库连接池

	compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1')
	compile('mysql:mysql-connector-java')

thymeleaf插件
(nekohtml能够有效的避免html页面中缺少/引起的报错)

	compile 'net.sourceforge.nekohtml:nekohtml:1.9.12'
	compile 'org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE'

3.2 配置文件

server.port= 8070

#数据库连接(useSSL=true能够有效的避免mysql版本过高引起的报错)
spring.datasource.url=jdbc:mysql://localhost:3306/mydb?useSSL=true&verifyServerCertificate=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

#配置mybatis需要扫描的包
mybatis.typeAliasesPackage=com.example.demo.entity
mybatis.mapperLocations=classpath:mapper/*Mapper.xml

#配置thymeleaf要扫描的html所在的包
spring.thymeleaf.prefix=classpath:/static
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5

3.3 项目结构

项目结构

3.4 代码内容

3.4.1 实体类Person.java

这边省略了set和get(这个是很小的demo 偷懒了)

package com.example.demo.entity;

public 
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BigFishXYH

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值