Commit 152d3a4e36e652cc913a0e8943ea00cf5b913007
1 parent
76a431b8
```
refactor(mqtt): 重构项目模块结构,提取web模块 - 将 GlobalExceptionHandler 从 mqtt-core 移至 mqtt-web 模块 - 将 Message 类从 mqtt-core 移至 mqtt-web 模块 - 将 PageQuery 类从 mqtt-core 移至 mqtt-web 模块 - 将 Valid 类从 mqtt-core 移至 mqtt-web 模块 - 将 MessageConfirmType 从 config 包移动到 type 包 - 创建新的 mqtt-web 模块并配置相关依赖 - 在 mqtt-boot 中添加 WebConfig 配置类引用 - 从 mqtt-core 移除 web 相关依赖,仅保留 json 依赖 - 更新项目主 pom.xml 添加 mqtt-web 模块 ```
Showing
12 changed files
with
66 additions
and
16 deletions
mqtt-boot/pom.xml
| ... | ... | @@ -23,6 +23,11 @@ |
| 23 | 23 | <version>${revision}</version> |
| 24 | 24 | </dependency> |
| 25 | 25 | <dependency> |
| 26 | + <groupId>com.diligrp</groupId> | |
| 27 | + <artifactId>mqtt-web</artifactId> | |
| 28 | + <version>${revision}</version> | |
| 29 | + </dependency> | |
| 30 | + <dependency> | |
| 26 | 31 | <groupId>org.springframework.cloud</groupId> |
| 27 | 32 | <artifactId>spring-cloud-starter-bootstrap</artifactId> |
| 28 | 33 | </dependency> | ... | ... |
mqtt-boot/src/main/java/com/diligrp/mqtt/boot/MqttApplication.java
| 1 | 1 | package com.diligrp.mqtt.boot; |
| 2 | 2 | |
| 3 | -import com.diligrp.mqtt.vertx.VertxConfig; | |
| 4 | 3 | import com.diligrp.mqtt.core.CoreConfig; |
| 4 | +import com.diligrp.mqtt.vertx.VertxConfig; | |
| 5 | +import com.diligrp.mqtt.web.WebConfig; | |
| 5 | 6 | import org.springframework.boot.SpringApplication; |
| 6 | 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 7 | 8 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
| ... | ... | @@ -14,7 +15,7 @@ import org.springframework.context.annotation.Import; |
| 14 | 15 | */ |
| 15 | 16 | @SpringBootApplication |
| 16 | 17 | @EnableDiscoveryClient |
| 17 | -@Import({CoreConfig.class, VertxConfig.class}) | |
| 18 | +@Import({CoreConfig.class, VertxConfig.class, WebConfig.class}) | |
| 18 | 19 | public class MqttApplication { |
| 19 | 20 | public static void main(String[] args) { |
| 20 | 21 | SpringApplication.run(MqttApplication.class, args); | ... | ... |
mqtt-core/pom.xml
| ... | ... | @@ -16,11 +16,7 @@ |
| 16 | 16 | <dependencies> |
| 17 | 17 | <dependency> |
| 18 | 18 | <groupId>org.springframework.boot</groupId> |
| 19 | - <artifactId>spring-boot-starter-web</artifactId> | |
| 20 | - </dependency> | |
| 21 | - <dependency> | |
| 22 | - <groupId>org.springframework.boot</groupId> | |
| 23 | - <artifactId>spring-boot-starter-validation</artifactId> | |
| 19 | + <artifactId>spring-boot-starter-json</artifactId> | |
| 24 | 20 | </dependency> |
| 25 | 21 | <dependency> |
| 26 | 22 | <groupId>io.vertx</groupId> | ... | ... |
mqtt-core/src/main/java/com/diligrp/mqtt/core/exception/MqttServiceException.java
mqtt-core/src/main/java/com/diligrp/mqtt/core/config/MessageConfirmType.java renamed to mqtt-core/src/main/java/com/diligrp/mqtt/core/type/MessageConfirmType.java
mqtt-web/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | + <modelVersion>4.0.0</modelVersion> | |
| 6 | + | |
| 7 | + <artifactId>mqtt-web</artifactId> | |
| 8 | + <version>${revision}</version> | |
| 9 | + <packaging>jar</packaging> | |
| 10 | + | |
| 11 | + <parent> | |
| 12 | + <groupId>com.diligrp</groupId> | |
| 13 | + <artifactId>mqtt-agent</artifactId> | |
| 14 | + <version>${revision}</version> | |
| 15 | + </parent> | |
| 16 | + <dependencies> | |
| 17 | + | |
| 18 | + <dependency> | |
| 19 | + <groupId>com.diligrp</groupId> | |
| 20 | + <artifactId>mqtt-core</artifactId> | |
| 21 | + <version>${revision}</version> | |
| 22 | + </dependency> | |
| 23 | + <dependency> | |
| 24 | + <groupId>org.springframework.boot</groupId> | |
| 25 | + <artifactId>spring-boot-starter-web</artifactId> | |
| 26 | + </dependency> | |
| 27 | + <dependency> | |
| 28 | + <groupId>org.springframework.boot</groupId> | |
| 29 | + <artifactId>spring-boot-starter-validation</artifactId> | |
| 30 | + </dependency> | |
| 31 | + </dependencies> | |
| 32 | + | |
| 33 | +</project> | ... | ... |
mqtt-web/src/main/java/com/diligrp/mqtt/web/WebConfig.java
0 → 100644
| 1 | +package com.diligrp.mqtt.web; | |
| 2 | + | |
| 3 | +import org.springframework.context.annotation.ComponentScan; | |
| 4 | +import org.springframework.context.annotation.Configuration; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * @Author: zhangmeiyang | |
| 8 | + * @CreateTime: 2025-12-30 16:36 | |
| 9 | + * @Version: todo | |
| 10 | + */ | |
| 11 | +@Configuration | |
| 12 | +@ComponentScan(basePackages = "com.diligrp.mqtt.web") | |
| 13 | +public class WebConfig { | |
| 14 | +} | ... | ... |
mqtt-core/src/main/java/com/diligrp/mqtt/core/config/GlobalExceptionHandler.java renamed to mqtt-web/src/main/java/com/diligrp/mqtt/web/config/GlobalExceptionHandler.java
| 1 | -package com.diligrp.mqtt.core.config; | |
| 1 | +package com.diligrp.mqtt.web.config; | |
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | import com.diligrp.mqtt.core.exception.MqttServiceException; |
| 5 | -import com.diligrp.mqtt.core.message.Message; | |
| 5 | +import com.diligrp.mqtt.web.message.Message; | |
| 6 | +import com.diligrp.mqtt.core.type.MessageConfirmType; | |
| 6 | 7 | import com.fasterxml.jackson.databind.exc.InvalidFormatException; |
| 7 | 8 | import jakarta.validation.ConstraintViolation; |
| 8 | 9 | import jakarta.validation.ConstraintViolationException; | ... | ... |
mqtt-core/src/main/java/com/diligrp/mqtt/core/message/Message.java renamed to mqtt-web/src/main/java/com/diligrp/mqtt/web/message/Message.java
mqtt-core/src/main/java/com/diligrp/mqtt/core/message/PageQuery.java renamed to mqtt-web/src/main/java/com/diligrp/mqtt/web/message/PageQuery.java
mqtt-core/src/main/java/com/diligrp/mqtt/core/message/Valid.java renamed to mqtt-web/src/main/java/com/diligrp/mqtt/web/message/Valid.java