REST API的spring-boot-starter-web和spring-boot-starter-data-rest的区别 [英] Difference for spring-boot-starter-web and spring-boot-starter-data-rest for REST APIs
问题描述
我正在尝试找出Spring中开发REST API的最佳实践.
I'm trying to figure out the best practise in Spring to develop a REST API.
我找到了这两个软件包,据我了解它们之间的区别是:
I found those two packages and as far as I understand the difference between them is:
- Web在REST API之上还支持其他功能
- 网络通过控制器管理资源访问
- data-rest通过存储库管理资源访问
有什么我想念的吗?大多数示例都位于Web之上,所以我想知道哪些决策要点会导致我在应用程序中偏向于另一个.
Is there anything that I'm missing? Most examples are on top of web so I wonder what decisions points would lead me to favor one over the other in my app.
推荐答案
这取决于您的需求.两者都是-web- 启动器(它们很容易将jar添加到您的类路径中),可以帮助您创建 REST API ,但数据静止具有更具体的用途,它可以帮助您将存储库公开为 REST 服务(实际上,如果您看到它们的 pom.xml , data-rest 取决于 stater-web ).如果那是您想要的,瞧!但是,如果您想更好地控制数据,控制器,验证或项目结构,则可以选择 stater-web .
Well it depends on what you want. Both are -web- starters (they make easy to add jars to your classpath) that will help you make a REST API, but data-rest has a more specific purpose, it help you to expose repositories as a REST services (In fact if you see their pom.xml, data-rest depends on stater-web). If that is what you want, voila! But if you want more control over the data, controllers, validation or project structure, stater-web is your option.
这篇关于REST API的spring-boot-starter-web和spring-boot-starter-data-rest的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!