spring boot jpa寫原生sql報Cannot resolve table錯誤解決方法
阿新 • • 發佈:2020-01-07
錯誤如圖
開啟View→Tool Windows→Persistence選項
在彈出的Persistence視窗的專案上右鍵,選擇Generate Persistence Mapping→By Database Schema
在此處進行資料庫相關配置,配置成功後即可在下方看到資料庫中的表
選擇下載driver files,或者使用自己本地的connector
自定義連線
填寫mysql相關的配置資訊
選擇data source,就可以看到資料庫相關的配置了。
在彈出的Persistence視窗的專案上右鍵,選擇Assign Data Sources...
選擇上面我們自定義的資料庫配置
然後在程式中加上庫的名字就可以了。
@Repository public interface CollectSwitchRepository extends JpaRepository<CollectSwitchEntity,Integer> { @Modifying @Query(nativeQuery = true,value = "update rexel_hzzg.COLLECT_SWITCH t set t.collect = :collect") public void updateOne(@Param("collect") String collect); }
一套連招下來之後,錯誤解決。
以上就是我們碰到這個問題後的解決方法,大家可以嘗試下,感謝大家對我們的支援。