No data sources are configured to run this SQL and provide advanced code assistance-笔记
作者:mmseoamin日期:2024-02-05

mapper文件或xml文件 提示:No data sources are configured to run this SQL and provide advanced code assistance. SQL dialect is not configured. 

在springboot项目中的mapper文件夹编写mapper文件或xml文件时,在显示框顶部显示如下提示:

No data sources are configured to run this SQL and provide advanced code assistance. 

SQL dialect is not configured. 

具体如截图所示:

No data sources are configured to run this SQL and provide advanced code assistance-笔记,第1张

解决办法:

一、先解决第一个,也就是“No data sources are configured to run this SQL and provide advanced code assistance.”这个问题

这里以连接MySQL为例

1、点击idea后边菜单栏中的Database

2、在弹出的页面中点击—>Data Source Properties

3、在弹出的页面中不用填写任何信息,直接点击Apply—>OK即可,原因:mysql的连接application.properties或application.yml中配置,这里不填写不影响项目的启动

No data sources are configured to run this SQL and provide advanced code assistance-笔记,第2张

No data sources are configured to run this SQL and provide advanced code assistance-笔记,第3张

二、解决第二个,也就是“SQL dialect is not configured. ”这个问题:

在File---->Settings--->Languages & Frameworks--->SQL Dialects中,选择对应的数据库,如MySQL,之后点击保存即可。

No data sources are configured to run this SQL and provide advanced code assistance-笔记,第4张