繁体   English   中英

Spring 数据 JPA 没有整个 Spring 引导应用程序

[英]Spring data JPA WITHOUT an entire Spring Boot application

我正在创建一个与 PostgreSQL 数据库通信的内部 CLI,并且易于创建无代码存储库是说服我选择 Spring 数据 Z9CE3D1BD8890F16A0C448093595087 的功能之一。

但是,我无法找到一些教程或 GitHub 存储库来设置 Spring 数据 JPA 项目而没有整个 Z2A2D4D4D4D565E6B2A0B23 启动应用程序2。

在项目https://github.com/spring-projects/spring-data-book/tree/master/jpa上没有主入口点,所以代码不可运行,顺便说一句,它是 8 年前更新的...

This other StackOverflow thread Spring Data JPA without Spring Boot does not help me because the guy could run his spring application on Google Cloud Platform finally (that was the cause of why he ask how to setup sping data jpa without spring boot).

我不知道如何开始,如果您有任何想法,我很乐意与比我更有经验的人讨论。

谢谢你。

如果没有更多完整的教程出现,这可能会有所帮助https://docs.spring.io/spring-data/jpa/docs/1.5.0.RELEASE/reference/html/repositories.ZFC35FDC70D5FC67D236E8A822C

查找此部分

独立使用

您还可以在 Spring 容器之外使用存储库基础架构,例如在 CDI 环境中。 您仍然需要在类路径中添加一些 Spring 库,但通常您也可以通过编程方式设置存储库。 提供存储库支持的 Spring 数据模块提供了一个特定于持久性技术的 RepositoryFactory,您可以按如下方式使用它

特别是它说您可以使用工厂来生成存储库:

RepositoryFactorySupport factory = … // Instantiate factory here
UserRepository repository = factory.getRepository(UserRepository.class);

So adding the spring parts that contain the spring data classes may be enough for this level and if you want to have DI, too, you likely need to combine them with the respective spring dependencies and configure a regular spring application.

暂无
暂无

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

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