我有依赖spring-boot-starter-data-jpa
JPA 的配置在application.properties内:
spring.datasource.url=jdbc:mysql://localhost:3306/db?serverTimezone=UTC
spring.datasource.username=name
spring.datasource.password=pass
...
当我创建@Entity 时:
@Entity
@Table(name="cats")
public class Cat {
@Column(name="age")
private int age;
....
}
它运作良好。当我尝试使用JPQL时:
"select cat from Cat cat"
Intellij idea 强调它说“Can't resolve symbol Cat”,我点击更多 “This checks controls是否 Persistence QL Queries are error-checked”。
值得一提的是,它可以正常工作,没有错误和异常。
为了解决它,有人在Intellij中推荐:
项目结构 - 方面 - 添加 - JPA。
之后,Intellij停止在JPQL语法附近显示此警告,但开始在我的Entity.class中的@Column(name="name")和@Table(name="cats")附近显示警告。
如何配置 JPA在 JPQL 和 Entity.class 中都不会收到此警告?
凤凰求蛊
相关分类