【发布时间】:2021-10-02 02:08:25
【问题描述】:
我想使用 JPA 存储库对 JSON 文件进行 CRUD 操作。
我尝试使用 JSON Populators 作为 described by Baeldung。
但它给了我org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory'。
有没有其他方法可以在不使用 Json 文件指定任何数据库的情况下进行 JPA 操作?
【问题讨论】:
-
到目前为止你尝试了什么?
-
我尝试了 JSON Populators,JPA 方法的自定义实现,不包括 {DataSourceAutoConfiguration.class},尝试使用 json 中的类字段 [{"_class":"com.customer.model.Customer","customerId ":2,"firstName":"Rahul"}]
-
你应该在你的问题中添加一些代码
-
我会,但我想确定这件事是否可能?我们可以在 JPA 中将文件配置为数据源并对其进行操作吗?
-
除非有允许使用 JSON 作为数据源的 JDBC 驱动程序,否则无法通过 JSON 文件使用 JPA。 JPA 与 JDBC 相关联。您所遵循的“教程”不是使用 JSON 作为 JPA,而是使用 JSON 填充数据库(名称填充器应该放弃它)。
标签: java json spring spring-boot spring-data-jpa