package com.sandu.ximon.admin.utils;
|
|
import com.aliyuncs.DefaultAcsClient;
|
import com.aliyuncs.profile.DefaultProfile;
|
import com.aliyuncs.profile.IClientProfile;
|
import com.sandu.ximon.admin.config.CommonConfig;
|
import org.springframework.stereotype.Component;
|
|
@Component("ClientUtils")
|
public class ClientUtils {
|
|
public static ClientUtils getBean(){
|
return (ClientUtils)SpringContextUtils.getBean("ClientUtils");
|
}
|
|
public DefaultAcsClient getClient() {
|
DefaultAcsClient client = null;
|
|
try {
|
IClientProfile profile = DefaultProfile.getProfile(
|
CommonConfig.REGION_ID,
|
CommonConfig.ACCESS_KEY_ID,
|
CommonConfig.ACCESS_KEY_SECRET
|
);
|
DefaultProfile.addEndpoint(
|
CommonConfig.REGION_ID,
|
CommonConfig.REGION_ID,
|
CommonConfig.PRODUCT_CODE,
|
CommonConfig.DOMAIN
|
);
|
// 初始化client
|
client = new DefaultAcsClient(profile);
|
|
} catch (Exception e) {
|
System.out.println("初始化client失败!exception:" + e.getMessage());
|
}
|
|
return client;
|
}
|
|
|
}
|