Springboot連線資料庫遇到的問題

2022-07-19 04:51:12 字數 1356 閱讀 9453

@table=(name ="

user

")

"user"一直報紅。點選顯示 cannot resolve table user。

解決方案:

file-->project structure-->modules-->選擇「+」-->hibernate-->點選descriptors的+-->ok-->

在idea執行的框裡找到左邊的persistence-->找到自己的專案assign data sources-->在裡面新增自己的資料庫

問題:

選擇框沒有當前的資料庫,原因可能是沒有配置當前資料庫。

解決方案:

點選右側database-->點選「+」-->選擇對應要用的資料庫型別-->新增資料庫

問題:

仍然未出現已經建立的資料庫

解決方案:

點選右側database-->點選上方圖示進入data sources and drivers-->點選schemas-->手動新增需要的資料庫

小tips:

在資料庫連線輸入使用者密碼以後,出現server returns invalid timezone. go to 'advanced' tab and set 'servertimezone' prope。這主要是指時區有問題。

解決方案:

非常簡單,只需要在cmd進入mysql以後,輸入屬下兩行**:

show variables like'

%time_zone

';

setglobal time_zone = '

+8:00

';

關於@table:

作用:宣告此物件對映到資料庫的資料表,通過它可以指定實體表。

@table(name="

tab_user

") //

其中name就是實體類對應的資料庫表的名字

@table(name = "

tab_user

",uniqueconstraints = )}) //

uniqueconstraints 用來批量命名唯一鍵

@table 註解詳解

intellij idea 配置mysql資料庫 詳解

idea連線mysql又報錯!

springboot無法連線資料庫問題

springboot使用yml配置檔案配置資料庫連線資訊時,如果資料庫密碼為純數字,需要加雙引號 否則會報access denied for user root localhost 錯誤。spring name crowd mysql datasource url jdbc mysql localh...

spring boot 不連線資料庫啟動,報錯問題

用spring boot 搭建的專案,在配置檔案不連線資料庫啟動專案會報錯。原因在於 spring boot缺省會載入 org.springframework.boot.autoconfigure.jdbc.datasourceautoconfiguration 類,datasourceautoco...

傳統方式和SpringBoot連線資料庫的兩種方式

1.編寫db.properties的配置檔案 2.編寫jdbcconfig的工具類 configuration propertysource classpath jdbc.properties public class jdbcconfig private string driverclass va...