错误如图

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

 

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

 

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

 

 

打开View→Tool Windows→Persistence选项

 

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

 

 在弹出的Persistence窗口的项目上右键,选择Generate Persistence Mapping→By Database Schema

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

 

在此处进行数据库相关配置,配置成功后即可在下方看到数据库中的表

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

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

 

选择下载driver files,或者使用自己本地的connector

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

 

自定义连接

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

 

 

填写mysql相关的配置信息

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

 

 

选择data source,就可以看到数据库相关的配置了。

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

 

在弹出的Persistence窗口的项目上右键,选择Assign Data Sources...

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

 

 

选择上面我们自定义的数据库配置

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

 

 

然后在程序中加上库的名字就可以了。

@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错误

 

相关文章: