简体   繁体   English

Intellij IDE 在实体中显示错误突出显示

[英]Intellij IDE show error highlight in Entities

I open a spring boot project in IntelliJ IDEA 2020.1.2 (Ultimate Edition) , and I hot many error highlight in entities, like:我在IntelliJ IDEA 2020.1.2 (Ultimate Edition)中打开了一个 spring 引导项目,并且在实体中出现了许多错误突出显示,例如:

  • Cannot resolve table 'roles'无法解析表“角色”
  • Class 'RolesEntity' should have [public, protected] no-arg constructor Class 'RolesEntity' 应该有 [public, protected] 无参数构造函数
  • Cannot resolve table 'user_roles'无法解析表'user_roles'

But when I open my project in old version like IntelliJ IDEA 2019.3.3 (Community Edition) I don't see this problem.但是当我在IntelliJ IDEA 2019.3.3(社区版)等旧版本中打开我的项目时,我没有看到这个问题。

IntelliJ IDEA 2020.1.2 IntelliJ IDEA 2020.1.2

IntelliJ IDEA 2020.1.2

IntelliJ IDEA 2019.3.3 IntelliJ IDEA 2019.3.3

IntelliJ IDEA 2019.3.3

Any reason for this problem or any fix please?请问这个问题的任何原因或任何修复?

In IntelliJ idea go to在 IntelliJ 想法 go 到

Setting-> Inspections->JPA->Unresolved database reference in annotations-> severity(which is just right)-> change from error to week warnning. Setting->Inspections->JPA->Unresolved database reference in annotations->severity(刚刚好)->从错误变为周警告。

在此处输入图像描述

Try this one试试这个


File -> Project Structure文件 -> 项目结构

At left pane select "Facets".在左窗格 select “Facets”。 If there is no JPA listed, click "+" sign and add "JPA"如果没有列出 JPA,请单击“+”号并添加“JPA”

At bottom of same dialog, at "Default JPA Provider", select - "Hibernate", press "OK"在同一对话框的底部,在“默认 JPA 提供程序”,select -“休眠”,按“确定”

If you have error at @Table annotation, configure and choose data source如果@Table annotation 有错误,请配置并选择数据源

Table name for select now should be recognized as entity class name select 的表名现在应被识别为实体 class 名称


Reference: GintsGints - stackOverFlow userName参考: GintsGints - stackOverFlow 用户名

Try to click File> Invalidate Cache & Restart.尝试单击文件> 使缓存无效并重新启动。 This should help这应该有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM