spring boot3多模块项目工程搭建-下(团队开发模板)

news/2024/10/18 8:24:06/

⛰️个人主页:     蒾酒

🔥系列专栏:《spring boot>spring boot实战》


目录

写在前面

上文衔接

Common模块

DAO模块

Service模块

Web模块

API模块

写在最后 


写在前面

本文介绍了springboot开发后端服务,多模块项目工程搭建,各模块的常用依赖整合以及目录结构创建。坚持看完相信对你有帮助。

同时欢迎订阅springboot系列专栏,持续分享spring boot>spring boot的使用经验。


上文衔接

上文链接:

​​​​​​spring boot>spring boot3多模块项目工程搭建-上(团队开发模板)_多个module的springboot3项目配置-CSDN博客https://blog.csdn.net/qq_62262918/article/details/138279618?spm=1001.2014.3001.5501icon-default.png?t=N7T8https://blog.csdn.net/qq_62262918/article/details/138279618?spm=1001.2014.3001.5501上文已经初步搭建spring boot>spring boot多模块聚合工程,并成功运行。下面开始各模块目录结构搭建,常用依赖整合。

Common模块

本模块主要放通用工具类和方法,通用配置,异常处理,常量定义,实体类,公共组件,自定义注解等。

目录结构示例:

常用依赖:

<!-- 引入lombok -->
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId>
</dependency><!-- 引入参数校验依赖 -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId>
</dependency><!-- 引入jwt依赖 -->
<dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt</artifactId><version>0.9.1</version>
</dependency><!-- 如果jdk大于1.8,则还需导入以下依赖 -->
<dependency><groupId>javax.xml.bind</groupId><artifactId>jaxb-api</artifactId><version>2.3.1</version>
</dependency>

具体依赖根据项目实际添加

DAO模块

本模块负责与数据库进行交互,执行数据访问操作,主要放mapper和实体类

目录结构示例:

常用依赖:

<!-- mybatis-plus -->
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.5</version><exclusions><exclusion><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId></exclusion></exclusions>
</dependency><!-- mybatis -->
<dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>3.0.3</version>
</dependency><!-- mysql驱动 -->
<dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><version>8.2.0</version><scope>runtime</scope>
</dependency><!-- mybatis-plus代码生成器 -->
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-generator</artifactId><version>3.5.5</version>
</dependency><!-- 代码生成使用模板 -->
<dependency><groupId>org.apache.velocity</groupId><artifactId>velocity-engine-core</artifactId><version>2.3</version>
</dependency><!-- druid数据库连接池 -->
<dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-3-starter</artifactId><version>1.2.20</version>
</dependency><!-- 引入common模块 -->
<dependency><groupId>com.mijiu</groupId><artifactId>common</artifactId>
</dependency>

这里仅仅引入了mybatis/plus相关的所有依赖并未进行相关配置,配置可以参考:

Spring Boot3整合MyBatis Plus_springboot3整合mybatis-plus-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/qq_62262918/article/details/135734561?spm=1001.2014.3001.5501这篇是基于单模块结构整合的,多模块结构的整合就是放在对应模块即可。

Service模块

本模块包含应用程序的业务逻辑,负责处理业务规则和数据处理。主要放业务接口以及实现类

目录结构示例:

常用依赖:

<!-- 引入dao模块 -->
<dependency><groupId>com.mijiu</groupId><artifactId>dao</artifactId>
</dependency>

实际根据项目需求进行添加即可

Web模块

本模块负责处理请求,主要放控制类和web相关配置类以及web服务启动类

目录结构示例:

常用依赖:

<!-- web组件 -->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency><!--测试组件-->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope>
</dependency><!-- service模块 -->
<dependency><groupId>com.mijiu</groupId><artifactId>service</artifactId>
</dependency>

API模块

本模块用于定义应用程序的外部接口,一般放外部接口请求、响应、封装(收口简化调用),错误码、状态码枚举等

目录结构示例:

 常用依赖:

<!-- okhttp3 依赖 -->
<dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>4.12.0</version>
</dependency><!-- 引入common模块 -->
<dependency><groupId>com.mijiu</groupId><artifactId>common</artifactId>
</dependency>

写在最后 

spring boot>spring boot3多模块项目工程搭建各模块目录结构搭建,常用依赖引入到这里就结束了。任何问题评论区或私信讨论,欢迎指正


http://www.ppmy.cn/news/1463292.html

相关文章

【一竞技CS2】YaLLa 2024邀请TheMongolz和BB

1、近日YaLLa Compass 2024主办方已宣布了最后两支受邀参赛的队伍是TheMongolz和BB两支战队,赛事将于6月5日至9日间在阿联酋阿布扎比的Space 42 Arena举行,总奖金为40万美元。 值得一说的是本次赛事的12支参赛队伍中,Cloud9和FURIA尚未确定参赛阵容。在arT离队后,FURIA让青训队…

C语言——在头⽂件中#if、_STDC_等字⾏起什么作⽤?

一、问题 通常&#xff0c;⼀些程序员都不会去研究头⽂件中的内容是什么含义&#xff0c;总觉得乱乱的&#xff0c;有很多 #if、_STDC_、#line 等字符&#xff0c;那么这些字符都各代表什么呢&#xff0c;在头⽂件中又起到什么作⽤呢&#xff1f; 二、解答 在头⽂件中存在类似…

git常见的18条指令

使用git的时候有没有遗忘指令的情况呢&#xff1f;小编替大家整理出来了18条常用的指令&#xff0c;大家赶紧收藏起来吧&#xff01; gti常见的18条指令 序号指令含义1git init初始化一个仓库2git clone [url]克隆一个仓库3git add [file]添加文件到暂存区4git commit -m "…

了解Hive 工作原理:Hive 是如何工作的?

一、概念 1、Hive Apache Hive 是一个分布式的容错数据仓库系统&#xff0c;可实现大规模分析和便于使用 SQL 读取、写入和管理驻留在分布式存储中的PB级数据。 Hive是建立在Hadoop之上的数据仓库框架&#xff0c;它提供了一种类SQL的查询语言—HiveQL&#xff0c;使得熟悉S…

前端JS怎么更换颜色:探索JavaScript中的色彩变换魔法

前端JS怎么更换颜色&#xff1a;探索JavaScript中的色彩变换魔法 在前端开发中&#xff0c;JavaScript&#xff08;JS&#xff09;扮演着至关重要的角色&#xff0c;其中一项常见的任务便是动态地更改网页元素的颜色。这个过程看似简单&#xff0c;实则蕴含着丰富的技巧和深度…

使用Golang调用腾讯云邮件模版发送邮件

文章目录 一、腾讯云邮件模版创建1.1 发信域名配置1.2 发信地址设置1.3 发信模版设置 二、通过Golang发送邮件2.1 代码示例2.2 代码说明 三、常见问题3.1 UnsupportedRegion3.2 InvalidTemplateID 本文档介绍了如何使用Golang编写代码&#xff0c;通过腾讯云邮件服务&#xff0…

翻译《The Old New Thing》- Why are INI files deprecated in favor of the registry?

Why are INI files deprecated in favor of the registry? - The Old New Thing (microsoft.com)https://devblogs.microsoft.com/oldnewthing/20071126-00/?p24383 Raymond Chen 2007年11月26日 为什么弃用 INI 文件而改用注册表&#xff1f; 欢迎&#xff0c;Slashdot的读…

Vue中封装的数组方法有哪些,其如何实现页面更新

在Vue中&#xff0c;对响应式处理利用的是Object.defineProperty对数据进行拦截&#xff0c;而这个方法并不能监听到数组内部变化&#xff0c;数组长度变化&#xff0c;数组的截取变化等&#xff0c;所以需要对这些操作进行hack&#xff0c;让Vue能监听到其中的变化。