build():依赖版本号放到公共层统一管理
parent
add31c49fa
commit
0ed0f872e9
|
@ -82,30 +82,25 @@
|
|||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>5.1.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-openapi</artifactId>
|
||||
<version>0.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-console</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-util</artifactId>
|
||||
<version>0.2.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>cloudapi20160714</artifactId>
|
||||
<version>3.10.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
|
|
@ -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<String> generateInstance() throws Exception {
|
||||
public List<String> 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<String> 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();
|
||||
|
|
40
pom.xml
40
pom.xml
|
@ -43,6 +43,12 @@
|
|||
<knife4j-openapi3.version>4.1.0</knife4j-openapi3.version>
|
||||
<xxl-job-core.version>2.4.1</xxl-job-core.version>
|
||||
<swagger.an.jakarta.verison>2.2.8</swagger.an.jakarta.verison>
|
||||
<ecs20140526.version>5.1.8</ecs20140526.version>
|
||||
<tea-openapi.version>0.3.2</tea-openapi.version>
|
||||
<tea-console.version>0.0.1</tea-console.version>
|
||||
<tea-util.version>0.2.21</tea-util.version>
|
||||
<cloudapi20160714.version>3.10.1</cloudapi20160714.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
@ -287,6 +293,40 @@
|
|||
<artifactId>cloud-modules-enterprise-common</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>${ecs20140526.version}</version>
|
||||
</dependency>
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-openapi</artifactId>
|
||||
<version>${tea-openapi.version}</version>
|
||||
</dependency>
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-console</artifactId>
|
||||
<version>${tea-console.version}</version>
|
||||
</dependency>
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-util</artifactId>
|
||||
<version>${tea-util.version}</version>
|
||||
</dependency>
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>cloudapi20160714</artifactId>
|
||||
<version>${cloudapi20160714.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
Loading…
Reference in New Issue