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} + + +