springboot项目感受01

01.先构建springboot项目,注意springboot版本不要高于3.0,不兼容jdk1.8 。 注意项目名,包名(com.xxx),maven 的group id 与包名一致就好
maven项目的依赖有
spring web
mysql diver
jdbc api
thymeleaf
mybatis(以后使用mybatis-plus)

02.要写application.properties文件

有如下
##连接超时时间
mybatis.configuration.default-statement-timeout=30
##驼峰命名规则
mybatis.configuration.map-underscore-to-camel-case=true

mybatis.mapper-locations=classpath:/mapper/**/*.xml
#log
logging.level.com.example=DEBUG

spring datasource

spring.datasource.url=jdbc:mysql://localhost:3306/dbactivity?serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#thymeleaf
spring.thymeleaf.prefix=classpath:/templates/pages/
spring.thymeleaf.suffix=.html

03
导入数据源,在cmd界面界面下
第一步:登录mysql
mysql –uroot –proot
第二步:设置控制台编码方式
(如果文件中有中文要设置,因为提供的文件时utf-8编码,服务器客户端编码为gbk)
set names utf8;
第三步:执行goods.sql文件,路径为sql文件所在路径“\”换成“/”
source d:/goods.sql

04.要先写活动类,pojo,一个表一个pojo实体类对象,主要用于封装数据。这里的数据是前端的参数。使用post方法提交的参数,默认可以用一个用户实体来封装。get方法,明显的在url上使用参数,直接在controller类的方法 上使用参数。

pojo对象属性名和表的列名相同

在使用desc 表名 看一下列的数据类型

数据库 pojo包
varchar -------------string
bigint -----------------long
tinyint-----------------Short
text--------------------string
datetime--------------LocalDateTime

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值