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,6 +23,11 @@ | ||
| 23 | <version>${revision}</version> | 23 | <version>${revision}</version> |
| 24 | </dependency> | 24 | </dependency> |
| 25 | <dependency> | 25 | <dependency> |
| 26 | + <groupId>com.diligrp</groupId> | ||
| 27 | + <artifactId>mqtt-web</artifactId> | ||
| 28 | + <version>${revision}</version> | ||
| 29 | + </dependency> | ||
| 30 | + <dependency> | ||
| 26 | <groupId>org.springframework.cloud</groupId> | 31 | <groupId>org.springframework.cloud</groupId> |
| 27 | <artifactId>spring-cloud-starter-bootstrap</artifactId> | 32 | <artifactId>spring-cloud-starter-bootstrap</artifactId> |
| 28 | </dependency> | 33 | </dependency> |
mqtt-boot/src/main/java/com/diligrp/mqtt/boot/MqttApplication.java
| 1 | package com.diligrp.mqtt.boot; | 1 | package com.diligrp.mqtt.boot; |
| 2 | 2 | ||
| 3 | -import com.diligrp.mqtt.vertx.VertxConfig; | ||
| 4 | import com.diligrp.mqtt.core.CoreConfig; | 3 | import com.diligrp.mqtt.core.CoreConfig; |
| 4 | +import com.diligrp.mqtt.vertx.VertxConfig; | ||
| 5 | +import com.diligrp.mqtt.web.WebConfig; | ||
| 5 | import org.springframework.boot.SpringApplication; | 6 | import org.springframework.boot.SpringApplication; |
| 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | 8 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
| @@ -14,7 +15,7 @@ import org.springframework.context.annotation.Import; | @@ -14,7 +15,7 @@ import org.springframework.context.annotation.Import; | ||
| 14 | */ | 15 | */ |
| 15 | @SpringBootApplication | 16 | @SpringBootApplication |
| 16 | @EnableDiscoveryClient | 17 | @EnableDiscoveryClient |
| 17 | -@Import({CoreConfig.class, VertxConfig.class}) | 18 | +@Import({CoreConfig.class, VertxConfig.class, WebConfig.class}) |
| 18 | public class MqttApplication { | 19 | public class MqttApplication { |
| 19 | public static void main(String[] args) { | 20 | public static void main(String[] args) { |
| 20 | SpringApplication.run(MqttApplication.class, args); | 21 | SpringApplication.run(MqttApplication.class, args); |
mqtt-core/pom.xml
| @@ -16,11 +16,7 @@ | @@ -16,11 +16,7 @@ | ||
| 16 | <dependencies> | 16 | <dependencies> |
| 17 | <dependency> | 17 | <dependency> |
| 18 | <groupId>org.springframework.boot</groupId> | 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 | </dependency> | 20 | </dependency> |
| 25 | <dependency> | 21 | <dependency> |
| 26 | <groupId>io.vertx</groupId> | 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 | import com.diligrp.mqtt.core.exception.MqttServiceException; | 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 | import com.fasterxml.jackson.databind.exc.InvalidFormatException; | 7 | import com.fasterxml.jackson.databind.exc.InvalidFormatException; |
| 7 | import jakarta.validation.ConstraintViolation; | 8 | import jakarta.validation.ConstraintViolation; |
| 8 | import jakarta.validation.ConstraintViolationException; | 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
| 1 | -package com.diligrp.mqtt.core.message; | 1 | +package com.diligrp.mqtt.web.message; |
| 2 | 2 | ||
| 3 | -import com.diligrp.mqtt.core.config.MessageConfirmType; | 3 | +import com.diligrp.mqtt.core.type.MessageConfirmType; |
| 4 | 4 | ||
| 5 | public class Message<T> { | 5 | public class Message<T> { |
| 6 | private Integer code; | 6 | private Integer code; |
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
pom.xml
| @@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
| 12 | <module>mqtt-boot</module> | 12 | <module>mqtt-boot</module> |
| 13 | <module>mqtt-core</module> | 13 | <module>mqtt-core</module> |
| 14 | <module>mqtt-vertx</module> | 14 | <module>mqtt-vertx</module> |
| 15 | + <module>mqtt-web</module> | ||
| 15 | </modules> | 16 | </modules> |
| 16 | 17 | ||
| 17 | <properties> | 18 | <properties> |