当前位置:网站首页>代码目录结构
代码目录结构
2022-08-09 06:21:00 【ggaofeng】
1、有人是这样规划目录的
conf --> 数据库连接池(因使用了配置服务器,必须有)
model --> 实体类
controller --> 接口访问层
mapper --> 数据库访问层
service --> 业务处理层
impl --> 业务处理实现类
util --> 工具类
vo --> 表现层对象2、还有人是这样的

3、按照DDD,有人建议这样
- application
- interfaces
- domain
- repositories
- gateways
- controllers
- persistence
- mq
- client
- ...
application 对应DDD的应用层,主要内容为该限界上下文中所有的应用服务
interfaces 对gateways中除persistence之外的抽象,包括访问除数据库之外其他外部资源的抽象接口,以及访问第三方服务或其他限界上下文服务的抽象接口
domain 对应DDD的领域层,为了更好地体现repositories在基础设施层扮演的与外部资源打交道的网关语义,将repositories单独分离
repositories 代表DDD中战术设计阶段的资源库,如果不复杂,可合并到domain
gateways 对应DDD的基础设施层,其下可以视外部资源的集成需求划分不同的包
1)controller是对客户端提供接口的北向网关,等同于上下文映射中开放主机服务(OHS)的概念
2)persistence对应了repositories抽象
3)其余网关对应interfaces抽象,其中client包下的实现类与interfaces下的对应接口组合起来,等于上下文映射中“防腐层(ACL)”的概念
4、还有这样的
-- application 应用层
-- event 事件
-- publish 事件发布
-- subscribe 事件订阅
-- service 应用服务
-- domain 领域层
-- aggregate名称 聚合根目录
-- entity 实体
-- event 事件
-- repository 仓储
-- service 领域服务
-- aggregate名称
-- entity 实体
-- event 事件
-- repository 仓储
-- service 领域服务
-- infrastructure 基础设施层
-- config 存放配置相关
-- util 存放第三方服务
-- eventbus 事件总线
-- mq 消息中间件5、目录结构1中,controller差不多就包含了api/rest
因为spring mvc是mvc结构,controller是这样的
@controller
public class xxxController{
@RequestMapping("/hello")
public ModelAndView handleRequest(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse) throws Exception {
ModelAndView mav = new ModelAndView("index");
mav.addObject("message", "Hello Spring MVC");
return mav;
}
}
代码大概就是这样的。
业务处理,返回数据。这个就是M(模型)层。
JSP或其他模板文件,就是V(视图)层。
这个controller对象,就是C(处理器)层。springboot还是保留了controller这个单词(这个词在mvc中有意义,在ddd中没有意义)。同时也有rest这个词。
@RestController
public class Restful {
@GetMapping("/hello1")
public String hello1(@RequestParam String name,@RequestParam int age) {
在dropwizard中就没有controller这个单词了。他是标准的rest,认为所有东西都是Resource(资源)
public class HelloWorldResource {
@GET
@Path("/hello-world")
public Saying sayHello(@QueryParam("name") Optional<String> name) {
边栏推荐
- How to find package information and pin definitions for NXP S32K1xx series microcontrollers
- 四氧化三铁/硫化铋纳米复合材料([email protected]@BSABiS纳米颗粒)|树状大分子稳定的硫化铋纳米颗粒|科研试剂
- tidb 宕机测试
- 5年测试开发工程师感悟——写给还在迷茫中的朋友
- pdf加密、找回密码
- Fe3O4/SiO2 Composite Magnetic Nanoparticles Aminated on SiO2-NH2/Fe3O4 Surface (Qiyue Reagent)
- Deep Learning - Principles of Neural Networks 2
- Unity backgammon game design and simple AI implementation (1)
- AIOT介绍
- 记一个 nest.js 路由匹配后面所有路径问题
猜你喜欢
[email protected]@cadmium sulfide nanocore-shell structure material|Fe3O4 magnetic nanop"/>Superparamagnetic iron [email protected]@cadmium sulfide nanocore-shell structure material|Fe3O4 magnetic nanop

【Feel】Unity Feel插件中,Camera无法正确显示CameraShake
![[MySQL] Second, the relationship between processes, MySQL password cracking, table building and database building related commands](/img/20/a0fb44e9360837146d0ed696c9e992.png)
[MySQL] Second, the relationship between processes, MySQL password cracking, table building and database building related commands

二十四节气之立秋

带头双向循环链表的增删查改(C语言实现)

MYSQLg高级------批量插入百万级数据量
![[Deep Learning] Let's talk about what is convolutional neural network and what does convolution mean?](/img/12/c3258942e4dcc28714b57d5a3f725c.png)
[Deep Learning] Let's talk about what is convolutional neural network and what does convolution mean?

牛客每日刷题之链表

workbench 数据导出

关于如何查找NXP S32K1xx系列单片机的封装信息和引脚定义
随机推荐
Unity 五子棋游戏设计和简单AI(2)
Deep Learning - Principles of Neural Networks 2
Introduction to AIOT
Remember a nest.js route that matches all the path problems that follow
kubernetes apparmor入门
MYSQLg advanced ------ batch insert millions of data
聚酰胺-胺(PAMAM)树形聚合物-硫化铋复合纳米粒子|硫化铋修饰Gd‑DTPA‑OA配体|科研实验用
Introduction of convenient functions and convenient shortcut keys of vs tomato assistant
[HNOI2002]营业额统计
MYSQL Advanced Chapter - Query Interception Analysis, Lock Mechanism, Master-Slave Replication
Chapter 7. Image-based lighting
VB.net程序关闭后后台还在与SQL连接
excel表格如何不需鼠标往下拖动而自动往下填
A day to learn a public company: Sophia
MYSQL高级篇-----查询截取分析,锁机制,主从复制
[Deep Learning] Let's talk about what is convolutional neural network and what does convolution mean?
S7-200SMART PLC Modbus TCP通信
workbench 数据导出
[R language] interaction test data
Gao Zelong, a famous digital collection expert and founder of the Digital Collection Conference, was interviewed by China Entrepreneur Magazine