快速搭建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")

未完待續…

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