From 0ed0f872e96ee67a53fefc86e0ac19fc4f1e665f Mon Sep 17 00:00:00 2001
From: liuyibo <14460729+liuyibo12345@user.noreply.gitee.com>
Date: Mon, 30 Sep 2024 19:05:30 +0800
Subject: [PATCH] =?UTF-8?q?build():=E4=BE=9D=E8=B5=96=E7=89=88=E6=9C=AC?=
=?UTF-8?q?=E5=8F=B7=E6=94=BE=E5=88=B0=E5=85=AC=E5=85=B1=E5=B1=82=E7=BB=9F?=
=?UTF-8?q?=E4=B8=80=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cloud-modules-vehicle-gateway/pom.xml | 5 ---
.../instance/GenerateInstance.java | 19 ++++-----
pom.xml | 40 +++++++++++++++++++
3 files changed, 48 insertions(+), 16 deletions(-)
diff --git a/cloud-modules/cloud-modules-vehicle-gateway/pom.xml b/cloud-modules/cloud-modules-vehicle-gateway/pom.xml
index ced9de2..78a42aa 100644
--- a/cloud-modules/cloud-modules-vehicle-gateway/pom.xml
+++ b/cloud-modules/cloud-modules-vehicle-gateway/pom.xml
@@ -82,30 +82,25 @@
com.aliyun
ecs20140526
- 5.1.8
com.aliyun
tea-openapi
- 0.3.2
com.aliyun
tea-console
- 0.0.1
com.aliyun
tea-util
- 0.2.21
com.aliyun
cloudapi20160714
- 3.10.1
diff --git a/cloud-modules/cloud-modules-vehicle-gateway/src/main/java/com/muyu/vehiclegateway/instance/GenerateInstance.java b/cloud-modules/cloud-modules-vehicle-gateway/src/main/java/com/muyu/vehiclegateway/instance/GenerateInstance.java
index 627810b..4d5bd74 100644
--- a/cloud-modules/cloud-modules-vehicle-gateway/src/main/java/com/muyu/vehiclegateway/instance/GenerateInstance.java
+++ b/cloud-modules/cloud-modules-vehicle-gateway/src/main/java/com/muyu/vehiclegateway/instance/GenerateInstance.java
@@ -8,6 +8,7 @@ import com.aliyun.ecs20140526.models.RunInstancesRequest;
import com.aliyun.tea.TeaException;
import com.aliyun.teautil.Common;
import com.aliyun.teautil.models.RuntimeOptions;
+import com.muyu.common.redis.service.RedisService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,14 +32,15 @@ import java.util.List;
@Tag(name = "程序启动创建ECS服务器实例")
public class GenerateInstance implements ApplicationRunner {
+
@Autowired
- private static StringRedisTemplate redisTemplate;
+ private RedisService redisService;
/**
* 启动自动创建实例
* @throws Exception
*/
- public static List generateInstance() throws Exception {
+ public List generateInstance() throws Exception {
// 创建ECS客户端对象,用于后续调用ECS相关API
Client client = CreateClient.createClient();
@@ -50,7 +52,7 @@ public class GenerateInstance implements ApplicationRunner {
// 设置地域ID
.setRegionId("cn-shanghai")
// 设置镜像ID
- .setImageId("m-uf64hrlxa0rbmyd7ovvq")
+ .setImageId("m-uf63thq7h50ng72jpoq2")
// 设置实例类型
.setInstanceType("ecs.t6-c1m1.large")
// 设置安全组ID
@@ -70,7 +72,7 @@ public class GenerateInstance implements ApplicationRunner {
// 设置实例密码
.setPassword("Six@211206")
// 设置创建实例的数量
- .setAmount(2);
+ .setAmount(1);
RuntimeOptions runtime = new RuntimeOptions();
try {
@@ -115,20 +117,15 @@ public class GenerateInstance implements ApplicationRunner {
log.info("实例id为:"+instance.getInstanceId());
log.info("实例ip为:"+instance.getPublicIpAddress().ipAddress.get(0));
log.info("实例状态为:"+instance.getStatus());
+
}
-// redisTemplate.opsForList().rightPushAll("shili",list.toString());
-//
-// List shili = redisTemplate.opsForList().range("shili", 0, -1);
-// for (String string : shili) {
-// log.info("redis实例:"+string);
-// }
+ redisService.setCacheList("shili",list);
return list;
}
-
@Override
public void run(ApplicationArguments args) throws Exception {
generateInstance();
diff --git a/pom.xml b/pom.xml
index d807259..bd4bcfb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,12 @@
4.1.0
2.4.1
2.2.8
+ 5.1.8
+ 0.3.2
+ 0.0.1
+ 0.2.21
+ 3.10.1
+
@@ -287,6 +293,40 @@
cloud-modules-enterprise-common
${muyu.version}
+
+
+
+
+ com.aliyun
+ ecs20140526
+ ${ecs20140526.version}
+
+
+
+ com.aliyun
+ tea-openapi
+ ${tea-openapi.version}
+
+
+
+ com.aliyun
+ tea-console
+ ${tea-console.version}
+
+
+
+ com.aliyun
+ tea-util
+ ${tea-util.version}
+
+
+
+ com.aliyun
+ cloudapi20160714
+ ${cloudapi20160714.version}
+
+
+