Bladeren bron

Merge remote-tracking branch 'origin/master' into mqy20260511

mqy20260511
lenovo 2 weken geleden
bovenliggende
commit
ccfd3a4e7e

+ 8
- 8
CLAUDE.md Bestand weergeven

@@ -55,7 +55,7 @@ iot-platform/
55 55
 ### TDengine (Time-Series Database)
56 56
 - Used for high-frequency IoT telemetry ingestion
57 57
 - Connection pool: HikariCP via `TDengineService`
58
-- Connects to `jdbc:TAOS://localhost:6030/`
58
+- Connects to `jdbc:TAOS://127.0.0.1:6031/`
59 59
 - Super-table pattern with column caching (`stableColumnCache`)
60 60
 
61 61
 ### Redis
@@ -71,7 +71,7 @@ iot-platform/
71 71
 - `iot-platform/src/main/resources/application.yml` — Main config (port 8887, Redis, MyBatis, Actuator)
72 72
 - `iot-platform/src/main/resources/application-druid.yml` — Database connection (Druid pool, master/slave)
73 73
 - `iot-platform/src/main/resources/logback-spring.xml` — Logging config with rolling
74
-- `.env` — Environment variables (passwords, credentials) loaded by systemd or start.sh
74
+- `.env` — Environment variables (passwords, credentials) loaded by start-container.sh
75 75
 
76 76
 ## Environment Variables
77 77
 
@@ -134,18 +134,18 @@ Implementations:
134 134
 
135 135
 ## Deployment
136 136
 
137
-Production deployment uses systemd on online180 (47.104.204.180).
137
+Production deployment uses Podman containers on online180 (47.104.204.180).
138 138
 
139 139
 ```bash
140 140
 # Deploy from local
141 141
 cd deploy
142
-./deploy.sh --build          # Build and deploy
142
+./deploy.sh --build          # Build, build image, and deploy
143 143
 ./deploy.sh --jar <path>     # Deploy specific jar
144 144
 
145
-# Server management
146
-systemctl status iot-platform
147
-systemctl restart iot-platform
148
-journalctl -u iot-platform -f
145
+# Container management
146
+podman ps | grep iot-platform
147
+podman logs -f iot-platform
148
+podman restart iot-platform
149 149
 ```
150 150
 
151 151
 See `deploy/README.md` for full deployment documentation.

+ 57
- 26
deploy/README.md Bestand weergeven

@@ -2,42 +2,53 @@
2 2
 
3 3
 ## 概述
4 4
 
5
-本项目使用 systemd 管理进程,通过 `deploy.sh` 脚本实现一键构建、上传、备份、健康检查和自动回滚。
5
+本项目使用 Podman 容器化部署,通过 `deploy.sh` 脚本实现一键构建、上传、构建镜像、健康检查和自动回滚。
6 6
 
7 7
 ## 服务器环境
8 8
 
9 9
 - **服务器**: online180 (47.104.204.180)
10 10
 - **OS**: Alibaba Cloud Linux 3
11
-- **Java**: OpenJDK 1.8.0_412
11
+- **容器运行时**: Podman 4.9.4 (docker 兼容)
12
+- **Java**: OpenJDK 1.8 (容器内)
12 13
 - **安装目录**: `/opt/iot-platform/`
13
-- **服务名称**: `iot-platform`
14
+- **容器名称**: `iot-platform`
14 15
 
15 16
 ## 目录结构
16 17
 
17 18
 ```
18 19
 /opt/iot-platform/
19 20
 ├── iot-platform.jar          # 当前运行版本
21
+├── Dockerfile                # 容器镜像构建定义
22
+├── start-container.sh        # 容器启动脚本(加载 .env)
20 23
 ├── .env                      # 环境变量(密码、凭据)
21 24
 ├── backup/                   # 版本备份(自动创建)
22 25
 ├── bin/
23 26
 │   ├── deploy.sh             # 一键部署脚本(本地运行)
24 27
 │   └── health-check.sh       # 健康检查脚本
25 28
 ├── config/                   # 线上专属配置
26
-└── logs/                     # 日志输出
29
+└── logs/                     # 日志输出(宿主机挂载)
27 30
 ```
28 31
 
29 32
 ## 快速开始
30 33
 
31 34
 ### 首次部署(服务器初始化)
32 35
 
33
-如果服务器上还没有安装 systemd 服务,执行初始化:
36
+确保服务器上已有 `/opt/iot-platform/` 目录,并包含 `Dockerfile`、`.env`、`start-container.sh`:
37
+
38
+```bash
39
+# 从本地同步必要文件到服务器
40
+scp deploy/setup-server.sh root@47.104.204.180:/opt/iot-platform/
41
+scp .env root@47.104.204.180:/opt/iot-platform/
42
+scp Dockerfile root@47.104.204.180:/opt/iot-platform/
43
+scp start-container.sh root@47.104.204.180:/opt/iot-platform/
44
+ssh root@47.104.204.180 "chmod +x /opt/iot-platform/start-container.sh"
45
+```
46
+
47
+然后执行首次部署:
34 48
 
35 49
 ```bash
36 50
 cd deploy
37
-scp setup-server.sh root@47.104.204.180:/tmp/
38
-scp iot-platform.service root@47.104.204.180:/tmp/
39
-scp ../.env root@47.104.204.180:/tmp/iot-platform.env
40
-ssh root@47.104.204.180 "chmod +x /tmp/setup-server.sh && /tmp/setup-server.sh"
51
+./deploy.sh --build
41 52
 ```
42 53
 
43 54
 ### 日常部署
@@ -53,9 +64,9 @@ cd deploy
53 64
 1. 本地执行 `mvn clean package`
54 65
 2. 上传 jar 到服务器
55 66
 3. 备份当前版本(带时间戳)
56
-4. 停止 systemd 服务
57
-5. 替换 jar
58
-6. 启动服务
67
+4. 停止并删除旧容器
68
+5. 替换 jar 并构建新镜像
69
+6. 启动容器(host 网络模式)
59 70
 7. 健康检查(`/actuator/health`)
60 71
 8. 失败则自动回滚到上一个版本
61 72
 
@@ -104,20 +115,26 @@ DRUID_PASSWORD=...
104 115
 ## 服务器管理
105 116
 
106 117
 ```bash
107
-# 查看状态
108
-systemctl status iot-platform
118
+# 查看容器状态
119
+podman ps | grep iot-platform
109 120
 
110
-# 重启
111
-systemctl restart iot-platform
121
+# 查看实时日志
122
+podman logs -f iot-platform
112 123
 
113
-# 停止
114
-systemctl stop iot-platform
124
+# 查看最后 100 行日志
125
+podman logs --tail 100 iot-platform
115 126
 
116
-# 查看日志
117
-journalctl -u iot-platform -f
127
+# 查看宿主机上的日志文件(和容器内同步)
128
+tail -f /opt/iot-platform/logs/iot-platform.$(date +%Y-%m-%d).*.log
118 129
 
119
-# 查看历史日志
120
-journalctl -u iot-platform --since "1 hour ago"
130
+# 停止容器
131
+podman stop iot-platform
132
+
133
+# 删除容器
134
+podman rm iot-platform
135
+
136
+# 重启容器
137
+podman restart iot-platform
121 138
 ```
122 139
 
123 140
 ## 健康检查
@@ -142,10 +159,22 @@ curl -s http://47.104.204.180:8887/actuator/health
142 159
 
143 160
 ```bash
144 161
 ssh root@47.104.204.180
145
-systemctl stop iot-platform
162
+
163
+# 停止并删除当前容器
164
+podman stop iot-platform && podman rm iot-platform
165
+
166
+# 恢复旧版本 jar
146 167
 ls /opt/iot-platform/backup/          # 查看可用备份
147 168
 cp /opt/iot-platform/backup/iot-platform-XXXX.jar /opt/iot-platform/iot-platform.jar
148
-systemctl start iot-platform
169
+
170
+# 重新构建镜像并启动
171
+cd /opt/iot-platform && podman build -t iot-platform:latest .
172
+podman run -d \
173
+    --name iot-platform \
174
+    --network host \
175
+    --restart unless-stopped \
176
+    -v /opt/iot-platform/logs:/opt/iot-platform/logs \
177
+    localhost/iot-platform:latest
149 178
 ```
150 179
 
151 180
 ## 配置文件说明
@@ -153,6 +182,8 @@ systemctl start iot-platform
153 182
 | 文件 | 说明 |
154 183
 |------|------|
155 184
 | `deploy.sh` | 一键部署脚本(本地执行) |
156
-| `setup-server.sh` | 服务器初始化脚本(服务器执行) |
185
+| `setup-server.sh` | 服务器初始化脚本 |
157 186
 | `health-check.sh` | 健康检查脚本 |
158
-| `iot-platform.service` | systemd 服务定义 |
187
+| `Dockerfile` | 容器镜像构建定义 |
188
+| `start-container.sh` | 容器内启动脚本(加载 .env) |
189
+| `iot-platform.service` | systemd 服务定义(已废弃,保留备用) |

+ 40
- 20
deploy/deploy.sh Bestand weergeven

@@ -1,5 +1,5 @@
1 1
 #!/bin/bash
2
-# IoT Platform 一键部署脚本
2
+# IoT Platform 容器化一键部署脚本 (Podman)
3 3
 # 用法:
4 4
 #   ./deploy.sh --build              # 本地构建后部署
5 5
 #   ./deploy.sh --jar path/to/jar    # 使用指定 jar 部署
@@ -107,29 +107,40 @@ ssh "${SERVER_USER}@${SERVER_HOST}" "
107 107
 "
108 108
 echo -e "${GREEN}[2/6] 备份完成${NC}"
109 109
 
110
-# 步骤 3: 停止服务
111
-echo -e "${YELLOW}[3/6] 停止服务...${NC}"
112
-ssh "${SERVER_USER}@${SERVER_HOST}" "systemctl stop ${APP_NAME} || true"
110
+# 步骤 3: 停止旧容器
111
+echo -e "${YELLOW}[3/6] 停止旧容器...${NC}"
112
+ssh "${SERVER_USER}@${SERVER_HOST}" "podman stop ${APP_NAME} >/dev/null 2>&1 && podman rm ${APP_NAME} >/dev/null 2>&1 || true"
113 113
 sleep 2
114
-echo -e "${GREEN}[3/6] 服务已停止${NC}"
114
+echo -e "${GREEN}[3/6] 旧容器已清理${NC}"
115 115
 
116
-# 步骤 4: 替换 JAR
117
-echo -e "${YELLOW}[4/6] 替换 JAR...${NC}"
116
+# 步骤 4: 替换 JAR 并构建镜像
117
+echo -e "${YELLOW}[4/6] 替换 JAR 并构建镜像...${NC}"
118 118
 ssh "${SERVER_USER}@${SERVER_HOST}" "
119 119
     cp ${REMOTE_DIR}/tmp/${JAR_NAME} ${REMOTE_DIR}/${APP_NAME}.jar
120 120
     chmod 644 ${REMOTE_DIR}/${APP_NAME}.jar
121 121
     rm -f ${REMOTE_DIR}/tmp/${JAR_NAME}
122 122
     echo '  新 JAR:'
123 123
     ls -lh ${REMOTE_DIR}/${APP_NAME}.jar
124
+    echo '  构建镜像...'
125
+    cd ${REMOTE_DIR} && podman build -t ${APP_NAME}:latest . >/dev/null 2>&1
126
+    echo '  镜像构建完成'
127
+    podman images | grep ${APP_NAME}
124 128
 "
125
-echo -e "${GREEN}[4/6] 替换完成${NC}"
129
+echo -e "${GREEN}[4/6] 镜像构建完成${NC}"
126 130
 
127
-# 步骤 5: 启动服务
128
-echo -e "${YELLOW}[5/6] 启动服务...${NC}"
129
-ssh "${SERVER_USER}@${SERVER_HOST}" "systemctl start ${APP_NAME}"
130
-sleep 3
131
+# 步骤 5: 启动容器
132
+echo -e "${YELLOW}[5/6] 启动容器...${NC}"
133
+ssh "${SERVER_USER}@${SERVER_HOST}" "
134
+    podman run -d \
135
+        --name ${APP_NAME} \
136
+        --network host \
137
+        --restart unless-stopped \
138
+        -v ${REMOTE_DIR}/logs:/opt/iot-platform/logs \
139
+        localhost/${APP_NAME}:latest >/dev/null 2>&1
140
+"
141
+sleep 5
131 142
 
132
-echo -e "${GREEN}[5/6] 服务已启动${NC}"
143
+echo -e "${GREEN}[5/6] 容器已启动${NC}"
133 144
 
134 145
 # 步骤 6: 健康检查
135 146
 echo -e "${YELLOW}[6/6] 健康检查...${NC}"
@@ -144,8 +155,11 @@ if ssh "${SERVER_USER}@${SERVER_HOST}" "bash ${REMOTE_DIR}/bin/health-check.sh l
144 155
     echo "备份:     ${BACKUP_NAME}"
145 156
     echo "状态:     成功"
146 157
     echo ""
147
-    echo "服务状态:"
148
-    ssh "${SERVER_USER}@${SERVER_HOST}" "systemctl status ${APP_NAME} --no-pager"
158
+    echo "容器状态:"
159
+    ssh "${SERVER_USER}@${SERVER_HOST}" "podman ps | grep ${APP_NAME}"
160
+    echo ""
161
+    echo "查看日志:"
162
+    echo "  ssh ${SERVER_USER}@${SERVER_HOST} 'podman logs -f ${APP_NAME}'"
149 163
     exit 0
150 164
 else
151 165
     echo -e "${RED}[6/6] 健康检查失败!${NC}"
@@ -153,21 +167,27 @@ else
153 167
     if [ "$NO_ROLLBACK" = true ]; then
154 168
         echo -e "${YELLOW}[no-rollback] 已启用不回滚模式,保留新版本用于排查${NC}"
155 169
         echo -e "${YELLOW}排查命令:${NC}"
156
-        echo "  ssh ${SERVER_USER}@${SERVER_HOST} 'journalctl -u ${APP_NAME} -f'"
157
-        echo "  ssh ${SERVER_USER}@${SERVER_HOST} 'systemctl status ${APP_NAME}'"
170
+        echo "  ssh ${SERVER_USER}@${SERVER_HOST} 'podman logs -f ${APP_NAME}'"
171
+        echo "  ssh ${SERVER_USER}@${SERVER_HOST} 'podman ps | grep ${APP_NAME}'"
158 172
         exit 1
159 173
     fi
160 174
 
161 175
     echo -e "${YELLOW}[rollback] 执行回滚...${NC}"
162
-    ssh "${SERVER_USER}@${SERVER_HOST}" "systemctl stop ${APP_NAME} || true"
176
+    ssh "${SERVER_USER}@${SERVER_HOST}" "podman stop ${APP_NAME} >/dev/null 2>&1 && podman rm ${APP_NAME} >/dev/null 2>&1 || true"
163 177
 
164 178
     if ssh "${SERVER_USER}@${SERVER_HOST}" "test -f ${REMOTE_DIR}/backup/${BACKUP_NAME}"; then
165 179
         echo -e "${YELLOW}[rollback] 恢复旧版本...${NC}"
166 180
         ssh "${SERVER_USER}@${SERVER_HOST}" "
167 181
             cp ${REMOTE_DIR}/backup/${BACKUP_NAME} ${REMOTE_DIR}/${APP_NAME}.jar
168
-            systemctl start ${APP_NAME}
182
+            cd ${REMOTE_DIR} && podman build -t ${APP_NAME}:latest . >/dev/null 2>&1
183
+            podman run -d \
184
+                --name ${APP_NAME} \
185
+                --network host \
186
+                --restart unless-stopped \
187
+                -v ${REMOTE_DIR}/logs:/opt/iot-platform/logs \
188
+                localhost/${APP_NAME}:latest >/dev/null 2>&1
169 189
         "
170
-        sleep 3
190
+        sleep 5
171 191
 
172 192
         if ssh "${SERVER_USER}@${SERVER_HOST}" "bash ${REMOTE_DIR}/bin/health-check.sh localhost 8887 60"; then
173 193
             echo -e "${GREEN}[rollback] 回滚成功,旧版本已恢复${NC}"

+ 1
- 1
iot-platform/pom.xml Bestand weergeven

@@ -74,7 +74,7 @@
74 74
         <dependency>
75 75
             <groupId>com.taosdata.jdbc</groupId>
76 76
             <artifactId>taos-jdbcdriver</artifactId>
77
-            <version>3.2.7</version>
77
+            <version>3.3.2</version>
78 78
         </dependency>
79 79
 
80 80
         <!-- HikariCP (TdEngine 连接池) -->

+ 1
- 1
iot-platform/src/main/java/com/iot/platform/config/IotProperties.java Bestand weergeven

@@ -115,7 +115,7 @@ public class IotProperties {
115 115
      * TDengine配置
116 116
      */
117 117
     public static class TDengine {
118
-        private String url = "jdbc:TAOS://localhost:6030/";
118
+        private String url = "jdbc:TAOS://127.0.0.1:6031/";
119 119
         private String username = "";
120 120
         private String password = "";
121 121
 

+ 9
- 0
iot-platform/src/main/java/com/iot/platform/mqtt/MqttChargeStationConsumer.java Bestand weergeven

@@ -72,7 +72,16 @@ public class MqttChargeStationConsumer extends AbstractDynamicMqttConsumer {
72 72
         String dbName = topicParts[1];
73 73
         String superTable = topicParts[3];
74 74
         LocalDate date = LocalDate.now();
75
+//        String tableName = superTable + "_" + date.getYear() + String.format("%02d", date.getMonthValue());
75 76
         String tableName = superTable + "_" + date.getYear() + String.format("%02d", date.getMonthValue());
77
+
78
+        //拆分出数据库名称
79
+        //拆分出对于看哪个的超级表的名称
80
+
81
+        //字表名称公式
82
+
83
+        int i = ((int) "g".getBytes("UTF-8")[0]) % 10;
84
+
76 85
         tdengineService.insertBatch(dbName, superTable,tableName, batchToInsert);
77 86
     }
78 87
 }

+ 1
- 1
iot-platform/src/main/java/com/iot/platform/mqtt/MqttDynamicConsumer.java Bestand weergeven

@@ -44,7 +44,6 @@ public class MqttDynamicConsumer extends AbstractDynamicMqttConsumer {
44 44
         this.tdengineService = tdengineService;
45 45
         this.stringRedisTemplate = stringRedisTemplate;
46 46
     }
47
-
48 47
     @Override
49 48
     protected List<String> fetchTopics() {
50 49
         return sysControllerService.selectAll();
@@ -111,6 +110,7 @@ public class MqttDynamicConsumer extends AbstractDynamicMqttConsumer {
111 110
 
112 111
         List<Map<String, Object>> batch = Collections.singletonList(data);
113 112
 
113
+
114 114
 //        log.info("数据:({})",batch);
115 115
         tdengineService.insertBatch(ctx.dbName, ctx.superTable,tableName, batch);
116 116
     }

+ 21
- 6
iot-platform/src/main/java/com/iot/platform/service/TdEngineService.java Bestand weergeven

@@ -48,7 +48,7 @@ public class TdEngineService {
48 48
     private static final int MAX_COLUMNS_PER_INSERT = 100;
49 49
 
50 50
     // 默认 VARCHAR 字段长度限制
51
-    private static final int DEFAULT_VARCHAR_LENGTH = 255;
51
+    private static final int DEFAULT_VARCHAR_LENGTH = 128;
52 52
 
53 53
     // 东八区时区偏移(避免重复创建)
54 54
     private static final ZoneOffset ZONE_OFFSET_8 = ZoneOffset.of("+8");
@@ -328,6 +328,15 @@ public class TdEngineService {
328 328
      */
329 329
     private String buildInsertSql(String dbName, String table, String superTableName,
330 330
                                    Map<String, String> columnTypes, List<Map<String, Object>> dataList) {
331
+        return buildInsertSql(dbName, table, superTableName, columnTypes, dataList, null);
332
+    }
333
+
334
+    /**
335
+     * 构建批量插入 SQL(支持指定 timestamp)
336
+     */
337
+    private String buildInsertSql(String dbName, String table, String superTableName,
338
+                                   Map<String, String> columnTypes, List<Map<String, Object>> dataList,
339
+                                   Long customTs) {
331 340
         if (columnTypes.isEmpty()) {
332 341
             return null;
333 342
         }
@@ -335,6 +344,9 @@ public class TdEngineService {
335 344
         // 获取数据库中实际的列类型,用于格式化值
336 345
         Map<String, String> dbColumnTypes = getStableColumnTypes(dbName, superTableName);
337 346
 
347
+        // 使用统一的 timestamp,确保拆分插入时数据能合并到同一行
348
+        String tsValue = customTs != null ? String.valueOf(customTs) : "NOW()";
349
+
338 350
         StringBuilder sql = new StringBuilder();
339 351
         sql.append("INSERT INTO ").append(wrapName(dbName)).append(".").append(wrapName(table))
340 352
            .append(" (ts, surfacename");
@@ -350,7 +362,7 @@ public class TdEngineService {
350 362
                 continue;
351 363
             }
352 364
 
353
-            sql.append("(NOW(), '").append(escapeValue(superTableName)).append("'");
365
+            sql.append("(").append(tsValue).append(", '").append(escapeValue(superTableName)).append("'");
354 366
             for (Map.Entry<String, String> entry : columnTypes.entrySet()) {
355 367
                 String col = entry.getKey();
356 368
                 Object value = data.get(col);
@@ -428,6 +440,8 @@ public class TdEngineService {
428 440
             int totalCols = columnTypes.size();
429 441
             if (totalCols > MAX_COLUMNS_PER_INSERT) {
430 442
                 log.warn("列数({})超过单次插入限制({}),开始拆分插入", totalCols, MAX_COLUMNS_PER_INSERT);
443
+                // 生成统一的 timestamp,确保拆分插入时数据能合并到同一行
444
+                long unifiedTs = System.currentTimeMillis();
431 445
                 List<String> allColumns = new ArrayList<>(columnTypes.keySet());
432 446
                 int insertedCount = 0;
433 447
                 for (int i = 0; i < allColumns.size(); i += MAX_COLUMNS_PER_INSERT) {
@@ -439,13 +453,13 @@ public class TdEngineService {
439 453
                         subColumnTypes.put(col, columnTypes.get(col));
440 454
                     }
441 455
 
442
-                    String subSql = buildInsertSql(dbName, table, superTableName, subColumnTypes, dataList);
456
+                    String subSql = buildInsertSql(dbName, table, superTableName, subColumnTypes, dataList, unifiedTs);
443 457
                     if (subSql != null) {
444 458
                         stmt.executeUpdate(subSql);
445 459
                         insertedCount += dataList.size();
446 460
                     }
447 461
                 }
448
-                log.info("拆分插入完成 | 总列数: {} | 拆分批次数: {} | 插入行数: {}", totalCols, (totalCols + MAX_COLUMNS_PER_INSERT - 1) / MAX_COLUMNS_PER_INSERT, insertedCount);
462
+                log.info("拆分插入完成 | 总列数: {} | 拆分批次数: {} | 插入行数: {} | unifiedTs: {}", totalCols, (totalCols + MAX_COLUMNS_PER_INSERT - 1) / MAX_COLUMNS_PER_INSERT, insertedCount, unifiedTs);
449 463
             } else {
450 464
                 stmt.executeUpdate(sql);
451 465
             }
@@ -620,7 +634,9 @@ public class TdEngineService {
620 634
     /**
621 635
      * 确保表存在
622 636
      */
623
-    private void ensureTableExists(String dbName, String superTableName, String table) throws SQLException {
637
+    private void ensureTableExists(String dbName, String superTableName, String table)
638
+            throws SQLException {
639
+
624 640
         if (!isValidTableName(dbName) || !isValidTableName(superTableName) || !isValidTableName(table)) {
625 641
             throw new IllegalArgumentException("Invalid database or table name: dbName=" + dbName
626 642
                     + ", superTableName=" + superTableName + ", table=" + table);
@@ -687,5 +703,4 @@ public class TdEngineService {
687 703
             dataSource.close();
688 704
         }
689 705
     }
690
-
691 706
 }

+ 1
- 1
iot-platform/src/main/resources/application.yml Bestand weergeven

@@ -70,6 +70,6 @@ iot:
70 70
     password: ${MQTT_PASSWORD:}
71 71
     charge-station-topic: ${MQTT_CHARGE_STATION_TOPIC:station/ChargeStation/device/+/post/json}
72 72
   tdengine:
73
-    url: jdbc:TAOS://localhost:6030/
73
+    url: jdbc:TAOS://127.0.0.1:6031/
74 74
     username: ${TDENGINE_USERNAME:}
75 75
     password: ${TDENGINE_PASSWORD:}

+ 2
- 2
iot-platform/src/test/java/com/iot/platform/service/TDengineServiceTest.java Bestand weergeven

@@ -38,7 +38,7 @@ class TDengineServiceTest {
38 38
     @BeforeEach
39 39
     void setUp() {
40 40
         when(iotProperties.getTdengine()).thenReturn(tdengineConfig);
41
-        when(tdengineConfig.getUrl()).thenReturn("jdbc:TAOS://localhost:6030/test");
41
+        when(tdengineConfig.getUrl()).thenReturn("jdbc:TAOS://localhost:6031/test");
42 42
         when(tdengineConfig.getUsername()).thenReturn("root");
43 43
         when(tdengineConfig.getPassword()).thenReturn("taosdata");
44 44
     }
@@ -330,7 +330,7 @@ class TDengineServiceTest {
330 330
     @Test
331 331
     @DisplayName("getConnection: 数据源初始化失败时应抛异常")
332 332
     void getConnection_initFails_throwsException() {
333
-        when(tdengineConfig.getUrl()).thenReturn("jdbc:TAOS://invalid:6030/test");
333
+        when(tdengineConfig.getUrl()).thenReturn("jdbc:TAOS://invalid:6031/test");
334 334
 
335 335
         assertThatThrownBy(() -> tdengineService.getConnection())
336 336
                 .isInstanceOf(Throwable.class);

Laden…
Annuleren
Opslaan