在 Spring 数据中添加新的数据库支持



目前spring数据有多个数据库支持(mysql,cassandra,mongo..非常大的列表(,但是我想从头开始添加我的自定义存储库,例如在Spring Data中添加自定义数据库支持。我不想扩展任何现有的存储库,而是想为我的自定义数据源创建一个并行存储库支柱。查看当前的实现,它看起来像是一项繁琐的任务。如果有人能以最低的要求帮助我这样做,那就太好了。

您可以创建一个带有注释的存储库 Bean,您可以在其中注入 EntityManager 或执行类似操作的正确 Bean,具体取决于您使用的数据库类型。

@Repository
public class MyCustomRepositoryImpl implements MyCustomRepository {
@Autowired
private EntityManager entityManager;
//the methods that you are going to create.
}

有关更多详细信息,请参阅:

https://docs.spring.io/spring-data/data-commons/docs/1.6.1.RELEASE/reference/html/repositories.html 第 1.3 章 Spring 数据存储库的自定义实现

最新更新