解决JPA报错问题

我们在使用JPA做开发时可能会遇到下面的报错。

image-20231017091044527

这可能是你JPA版本问题,可以到pom.xml中看看JPA版本。

image-20231017091225461

注意,我这里使用的SpringBoot版本是2.7.16,但是我的JPA版本却是3.1.4,所以会报上面的错误。

这里需要JPA依赖坐标中的版本去掉。去掉之后,要记得刷新maven。

上面记录的是我如何解决这个问题的答案,如果你根据上面的操作没有效果,有可能是你其它地方配置错了。

下面是我的applicatin.properties的配置。

spring.data.jpa.repositories.enabled=true
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql = true

并且需要在启动类中添加扫描路径。

@EnableJpaRepositories(value = "top.lukeewin.jpa.repository")
lukeewin.jpa.repository")

猜你喜欢

转载自blog.csdn.net/qq_43907505/article/details/133876370
今日推荐