问题描述
我是弹簧靴的初学者.我参与了一个项目的开始,我们将使用 Spring Boot 构建休息服务.您能否建议在构建仅公开休息服务的项目时遵循的推荐目录结构?
I'm a beginner with spring boot. I'm involved in the beginning of a project where we would build rest services using spring boot. Could you please advise the recommended directory structure to follow when building a project that will just expose rest services?
推荐答案
你不需要做任何特别的事情就可以开始.从一个普通的 java 项目开始,maven 或 gradle 或具有 starter 依赖的 IDE 项目布局.
You do not need to do anything special to start. Start with a normal java project, either maven or gradle or IDE project layout with starter dependency.
您只需要一个主类,根据指南此处,然后休息...
You need just one main class, as per guide here and rest...
没有受约束的包结构.实际结构将由您的需求/心血来潮驱动,目录结构由 build-tool/IDE 奠定
您可以遵循与 Spring MVC 应用程序相同的结构.
You can follow same structure that you might be following for a Spring MVC application.
你可以按照任何一种方式
You can follow either way
一个项目分为几层:
A project is divided into layers:
例如:DDD风格
- 服务层:服务包包含服务类
- DAO/REPO层:包含dao类的dao包
- 实体层
或
适合您正在编写问题的问题的任何层结构.
any layer structure suitable to your problem for which you are writing problem.
一个项目分为模块或功能或特性,一个模块像上面一样分为多个层
A project divided into modules or functionalities or features and A module is divided into layers like above
我更喜欢第二种,因为它遵循商业环境.从概念的角度思考.
I prefer the second, because it follows Business context. Think in terms of concepts.
你做什么取决于你如何看待这个项目.这是你的代码组织技能.
What you do is dependent upon how you see the project. It is your code organization skills.
这篇关于Spring Boot Rest项目推荐的项目结构是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!