斷斷續(xù)續(xù)的學(xué)習(xí)了java的各種知識(shí),從javaEE,到j(luò)avaWeb,再到Spring,springmvc,mybatis ,期間穿插著也了解了前段的vue,typescript也有簡單的了解, 所學(xué)所看都是非常的分散,很多知識(shí)點(diǎn)也都是看了就忘,不能系統(tǒng)的消化,成為自己的知識(shí).
學(xué)習(xí)完springboot,其實(shí)也只是能夠簡單的使用, 很多原理都是一知半解, 總之還是不成系統(tǒng), 在繼續(xù)學(xué)習(xí)springcloud和寫個(gè)項(xiàng)目之間權(quán)衡之后,決定還是要先做一個(gè)項(xiàng)目, 在有項(xiàng)目基礎(chǔ),踩過很多的坑之后再去學(xué)習(xí)springcloud,這樣理解會(huì)更加的深刻.
所以決定將自己這段時(shí)間的學(xué)習(xí)都運(yùn)用到項(xiàng)目中, 只是為了學(xué)習(xí)知識(shí),項(xiàng)目本身并沒有什么出彩之處.
1. 項(xiàng)目的架構(gòu)是
SpringBoot: 2.3.7.RELEASE
mysql: 8.0.22
mybaits: 2.1.4
druid: 1.2.9
thymeleaf: 3.0.11.RELEASE
layui
2. 配置druid, 創(chuàng)建application.yml, 這個(gè)里面只配置用哪個(gè)環(huán)境
application-dev.yml dev環(huán)境
application-prod.yml 生產(chǎn)環(huán)境,
3. mybatis 需要再resource目錄下創(chuàng)建mapper文件夾,用來放mybatis的sql的xml文件
spring:
profiles:
active: dev
server:
port: 8081
spring:
datasource:
name: mysql_db
type: com.alibaba.druid.pool.DruidDataSource
#druid相關(guān)配置
druid:
#監(jiān)控統(tǒng)計(jì)攔截的filters
filters: stat
driver-class-name: com.mysql.cj.jdbc.Driver
#基本屬性
url: jdbc:mysql://127.0.0.1:3306/learnspringboot?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=UTC
username: root
password: 123456aa
#配置初始化大小/最小/最大
initial-size: 1
min-idle: 1
max-active: 20
#獲取連接等待超時(shí)時(shí)間
max-wait: 60000
#間隔多久進(jìn)行一次檢測,檢測需要關(guān)閉的空閑連接
time-between-eviction-runs-millis: 60000
#一個(gè)連接在池中最小生存的時(shí)間
min-evictable-idle-time-millis: 300000
validation-query: SELECT 'x'
test-while-idle: true
test-on-borrow: false
test-on-return: false
#打開PSCache,并指定每個(gè)連接上PSCache的大小。oracle設(shè)為true,mysql設(shè)為false。分庫分表較多推薦設(shè)置為false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
thymeleaf:
prefix: classpath:/templates/
check-template-location: true
suffix: .html
encoding: UTF-8
mode: HTML5
cache: false
check-template: true
content-type: text/html
enabled: true
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: cn.dtyy.pojo
到此整個(gè)架子就搭建完畢, springboot確實(shí)簡化了很多的配置,讓項(xiàng)目搭建的更加快捷
數(shù)據(jù)庫 的路徑?jīng)]有帶時(shí)區(qū) &serverTimezone=UTC
java.sql.SQLException: The server time zone value '?й???????' is unrecognized or
represents more than one time zone. You must configure either the server or
JDBC driver (via the 'serverTimezone' configuration property) to use a more
specific time zone value if you want to utilize time zone support.