55 lines
1.3 KiB
Java
55 lines
1.3 KiB
Java
package com.muyu.loadCenter.config;
|
|
|
|
import com.aliyun.ecs20140526.Client;
|
|
import com.aliyun.teaopenapi.models.Config;
|
|
import lombok.Data;
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
/**
|
|
* @ProjectName: LoadCenter
|
|
* @PackageName: com.muyu.loadCenter.aliyun.config
|
|
* @Description 阿里云配置类
|
|
* @Author HuangDaJu
|
|
* @Date 2024/4/16 14:48
|
|
* @Version 1.0
|
|
*/
|
|
|
|
@Data
|
|
@Configuration
|
|
@ConfigurationProperties(prefix = "config.ali")
|
|
public class AliConfig {
|
|
|
|
|
|
/**
|
|
* access-key-id
|
|
*/
|
|
private String accessKeyId;
|
|
/**
|
|
* access-key-secret
|
|
*/
|
|
private String accessKeySecret;
|
|
/**
|
|
* 地域id
|
|
*/
|
|
private String regionId;
|
|
|
|
|
|
|
|
@Bean
|
|
public Client createEcsClient(AliConfig aliConfig) throws Exception {
|
|
Config config = new Config()
|
|
// 您的AccessKey ID
|
|
.setAccessKeyId(aliConfig.getAccessKeyId())
|
|
// 您的AccessKey Secret
|
|
.setAccessKeySecret(aliConfig.getAccessKeySecret())
|
|
// 您的可用区ID
|
|
.setRegionId(aliConfig.getRegionId());
|
|
return new Client(config);
|
|
}
|
|
|
|
|
|
|
|
}
|