idea下spring boot jpa写原生sql的时候,报Cannot resolve table错误

Posted 大墨垂杨

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了idea下spring boot jpa写原生sql的时候,报Cannot resolve table错误相关的知识,希望对你有一定的参考价值。

错误如图

 

 

 

 

 

 

打开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);
}

 

一套连招下来之后,错误解决。

 

以上是关于idea下spring boot jpa写原生sql的时候,报Cannot resolve table错误的主要内容,如果未能解决你的问题,请参考以下文章