搭建sm運(yùn)行時(shí)報(bào)錯(cuò)
在用sm搭建項(xiàng)目報(bào)了如下一系列錯(cuò)誤,為遠(yuǎn)程連接mysql8時(shí)的錯(cuò)誤
image.png
image.png
解決方案
1.驅(qū)動(dòng)配置有誤:driver=com.mysql.cj.jdbc.Driver
2.數(shù)據(jù)庫(kù)連接地址有誤:url=jdbc:mysql://localhost:3306/test?3useUnicode=true&characterEncoding=utf8
3.密碼或帳號(hào)有誤:username=root
password=root
4.數(shù)據(jù)庫(kù)未啟動(dòng)或無(wú)權(quán)訪問(wèn)
5.mysql root沒(méi)有遠(yuǎn)程訪問(wèn)的權(quán)限盒至,需要增加權(quán)限窑业,增加權(quán)限的步驟如下:
進(jìn)入mysql數(shù)據(jù)庫(kù):
grant all privileges on . to 'root'@'%' identified by 'root' with grant option;
flush privileges;
如果上述都沒(méi)錯(cuò)的話就應(yīng)該是第6點(diǎn)這個(gè)錯(cuò)誤牌废,我便是遇到了這個(gè)錯(cuò)誤肖方,困擾了好幾天
6.mysql依賴引入無(wú)效,在項(xiàng)目中直接引入mysql-connector-8.0.16.jar包
image.png
后續(xù)可能會(huì)報(bào)時(shí)區(qū)異常
image.png
添加時(shí)區(qū)即可,需要在數(shù)據(jù)庫(kù) URL中設(shè)置serverTimezone屬性
image.png
其中 GMT%2B8 代表是東八區(qū)鸭限。
接下來(lái)接著報(bào)了連接池出c3p0版本過(guò)低問(wèn)題
image.png
只需將依賴版本提升到0.9.5.2即可
image.png
一系列錯(cuò)誤解決后項(xiàng)目即可運(yùn)行成功蜕径。