当前位置:网站首页>代码目录结构
代码目录结构
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) {
边栏推荐
- SiO2/KH550修饰四氧化三铁纳米磁性颗粒|PDA包裹四氧化三铁磁性纳米颗粒(科研级)
- Deep Learning - Principles of Neural Networks 2
- 牛客每日刷题之链表
- phpstudy 安装 flarum论坛
- 什么是excel文件保护
- Introduction to AIOT
- 22年下高项论文题目预测
- SiO2 / KH550 modified ferroferric oxide nano magnetic particles | PDA package the ferromagnetic oxide nanoparticles (research)
- zip压缩包密码解密
- Getting Started with MATLAB Image Processing
猜你喜欢
Unity C# 委托——事件,Action,Func的作用和区别
Unity backgammon game design and simple AI implementation (1)
list 字符串的输出方法 print(*a) print(““.join(str(c) for c in a) )
Xilinx Zynq ZynqMP DNA
[email protected]@cadmium sulfide nanocore-shell structure material|Fe3O4 magnetic nanop"/>
Superparamagnetic iron [email protected]@cadmium sulfide nanocore-shell structure material|Fe3O4 magnetic nanop
Chapter 3 Search and Graph Theory (1)
Getting Started with MATLAB Image Processing
【Feel】Unity Feel插件中,Camera无法正确显示CameraShake
vs番茄助手的方便功能和便捷快捷键介绍
static静态关键字和继承
随机推荐
[GO], arrays and slices
The 24th day of the special assault version of the sword offer
运算放大器(OPA)超详细参数讲解-运放---以及8个型号的运算放大器分析对比
mmdetection源码解析--ResNet18
【Feel】In the Unity Feel plugin, Camera cannot display CameraShake correctly
Build a "firewall" for safety and carry out firefighting training in Fengzhuang Township, Tongxu County, Henan Province
Qt 学习(三) —— Qt 模块
声母-字母查询工具-词语缩写查询在线工具
手把手教你用C语言制作七夕流星雨---优雅永不过时(详细教程)
CalBioreagents超全Id 蛋白兔单克隆抗体,助力科研
【R语言】对文件进行归一化整理到各文件类型文件夹
文本字符串长度排序 - 在线工具
Word文件的只读模式没有密码怎么退出?
MYSQLg高级------批量插入百万级数据量
Invalid argument(s) appears when redis runs lua script
[HNOI2002]营业额统计
How to automatically fill down an excel table without dragging the mouse down
Excel受保护的工作表怎么操作?
什么是excel文件保护
phpstudy 安装 flarum论坛