JAVA----SpingBoot 分模块开发

分模块

SpingBoot 分模块开发,便于协作,管理
mall 是域名

模块拆分
mall-crm-api     接口入口
mall-crm-admin   后台入口
mall-crm-service 服务层
mall-quartz      定时任务
mall-common      常用工具,分页,导出,支付,短信息发送,微信,Redis
mall-system      用户,角色,部门,菜单, 字典,日志等处理
mall-framework   国际化,鉴权,数据持久化
...
一般流程
1. 创建Spring Boot 项目, 确认主,子模块
2. 组合并引包
<!--删除了build,添加了packaging并且改为pom-->
<packaging>pom</packaging>
<modules>
	<module>mall-crm-admin</module>
	<module>mall-crm-api</module>
	<module>mall-crm-service</module>
	<module>mall-framework</module>
	<module>mall-common</module>
	<module>mall-system</module>
	<module>mall-quartz</module>
</modules>
3. 入口 admin,api 模块

配置模块间的依赖
添加依赖的子模块(一定要统一版本),修改打包build配置项

4. 不带入口子模块

删除其项目运行入口
删除不用的build 配置项
注意:如使用IEDA 工具要统一模块的版本(很重要),Setting---Build---Compiler---Java Complier
在这里插入图片描述

5. 打包

进入入口模块,项目右侧maven, 选择打包

模块创建

说明:只提供关键代码

模块引用
入口模块 引 框架模块
框架模块 引 系统模块
系统模块 引 通用模块

主模块配置
<properties>
	<java.version>1.8</java.version>
	<mall.version>1.0.1</mall.version>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<spring-boot.version>2.3.7.RELEASE</spring-boot.version>
	<mybatis.spring.version>2.1.4</mybatis.spring.version>
	<fastjson.version>1.2.60</fastjson.version>
	<druid.version>1.1.10</druid.version>
	<jedis.version>3.0.1</jedis.version>
	<shiro.version>1.6.0</shiro.version>
	<kaptcha.version>2.3.2</kaptcha.version>
</properties>

<packaging>pom</packaging>
<modules>
	<module>mall-crm-admin</module>
	<module>mall-crm-api</module>
	<module>mall-crm-service</module>
	<module>mall-framework</module>
	<module>mall-common</module>
	<module>mall-system</module>
	<module>mall-quartz</module>
</modules>

<dependencies>
	<!-- Mysql驱动包-->
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
	</dependency>

	<!-- 阿里数据库连接池-->
	<dependency>
		<groupId>com.alibaba</groupId>
		<artifactId>druid</artifactId>
		<version>${druid.version}</version>
	</dependency>
	
	<dependency>
	...
	</dependency>
</dependencies>		
framework模块
<parent>
	<groupId>com.mall</groupId>
	<artifactId>crm</artifactId>
	<version>1.0.1</version>
</parent>

<groupId>com.mall</groupId>
<artifactId>mall.framework</artifactId>
<version>1.0.1</version>
<name>framework</name>
<description>mall-framework</description>

<dependencies>
	<!-- web容器-->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter</artifactId>
	</dependency>

	<!-- aop 拦截器-->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-aop</artifactId>
	</dependency>

	<!-- thymeleaf-->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-thymeleaf</artifactId>
	</dependency>

	<!-- mybatis-->
	<dependency>
		<groupId>org.mybatis.spring.boot</groupId>
		<artifactId>mybatis-spring-boot-starter</artifactId>
		<version>${mybatis.spring.version}</version>
	</dependency>

	<!-- redis-->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-redis</artifactId>
	</dependency>

	<dependency>
		<groupId>org.apache.shiro</groupId>
		<artifactId>shiro-spring</artifactId>
		<version>${shiro.version}</version>
	</dependency>

	<!-- lombok-->
	<dependency>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
	</dependency>

	<dependency>
		<groupId>com.github.penggle</groupId>
		<artifactId>kaptcha</artifactId>
		<version>${kaptcha.version}</version>
	</dependency>

	<dependency>
		<groupId>com.mall</groupId>
		<artifactId>mall.system</artifactId>
		<version>${mall.version}</version>
	</dependency>
	
	<dependency>
	...
	<dependency>

</dependencies>
Admin, Api 模块
<parent>
	<groupId>com.mall</groupId>
	<artifactId>crm</artifactId>
	<version>1.0.1</version>
</parent>

<groupId>com.mall</groupId>
    <artifactId>mall.admin</artifactId>
    <version>1.0.1</version>
    <name>admin</name>
<description>mall-crm-admin</description>

<dependencies>
	<!-- framework-->
	<dependency>
		<groupId>com.mall</groupId>
		<artifactId>mall.framework</artifactId>
		<version>${mall.version}</version>
	</dependency>

	<!-- service-->
	<dependency>
		<groupId>com.mall</groupId>
		<artifactId>mall.service</artifactId>
		<version>${mall.version}</version>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
		<exclusions>
			<exclusion>
				<groupId>org.junit.vintage</groupId>
				<artifactId>junit-vintage-engine</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
	
	<dependency>
	...
	<dependency>
</dependencies>
其它模块, 如共用模块配置
<parent>
	<groupId>com.mall</groupId>
	<artifactId>crm</artifactId>
	<version>1.0.1</version>
</parent>

<groupId>com.mall</groupId>
<artifactId>mall.common</artifactId>
<version>1.0.1</version>
<name>common</name>
<description>公用工具类</description>

<properties>
...
</properties>

<dependencies>
...
</dependencies>
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
模块开发是一种将大型应用程序拆为多个独立模块开发方法。在Spring Boot中,可以使用模块开发来组织和管理项目的不同部。 在Spring Boot中,可以使用Maven或Gradle来创建和管理模块。每个模块都可以有自己的独立功能,并且可以在其他模块中进行引用和使用。 以下是使用Spring Boot进行模块开发的步骤: 1. 创建父模块:创建一个父模块作为整个项目的根目录。在父模块的pom.xml文件中,可以定义共享的依赖项和插件。 2. 创建子模块:在父模块下创建子模块,每个子模块都可以有自己的独立功能。可以使用Maven或Gradle创建子模块。 3. 定义依赖关系:在子模块的pom.xml文件中,可以定义该模块所依赖的其他模块或库。可以使用Maven或Gradle的依赖管理功能来管理依赖关系。 4. 编写代码:在每个子模块中编写相应的代码,实现各自的功能。 5. 构建和运行:使用Maven或Gradle构建整个项目,并运行主模块。 以下是一个示例的Spring Boot模块项目结构: ``` - parent-module - pom.xml - spring-common - pom.xml - src - main - java - com.example.common - CommonModule.java - spring-dao - pom.xml - src - main - java - com.example.dao - DaoModule.java - spring-service - pom.xml - src - main - java - com.example.service - ServiceModule.java ``` 在上面的示例中,父模块是`parent-module`,子模块包括`spring-common`、`spring-dao`和`spring-service`。每个子模块都有自己的pom.xml文件和相应的代码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值