快速搭建springboot项目

初始化项目架子

idea 新建一个Spring Initializr
在这里插入图片描述
选择组件spring web,mybatis,mysql-driver

新建完成

添加代码

采用idea插件[easycode],根据表直接生成一套代码
在这里插入图片描述
安装插件
在database中链接数据库
选中表右键生成一套代码

properties文件中配置如下

server.port=80
server.servlet.context-path=/
spring.datasource.url=jdbc:mysql://localhost/xxx?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=*.entity.*
logging.level.com.*.dao=debug #sql日志打印级别

杂七杂八

1.启动类中加@MapperScan注解

2.关于时间格式化的处理分为两种.接口返回前端和前端提交到接口.
接口返回前端
通过Jackson的@JsonFormat

@JsonFormat( pattern ="yyyy-MM-dd HH:mm:ss", timezone ="GMT+8")

前端提交到接口.
通过spring的@DateTimeFormat

 @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")

未完待续…

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章