EC2InstanceApp.java:
@SpringBootApplication @ EnableSwagger2 @ComponentScan(basePackages =“ com.publicis.sapient.ppc.analyticstool.createec2instance”) 公共类EC2InstanceApp {
public static void main(String[] args) {
SpringApplication.run(EC2InstanceApp.class, args);
}
}
InstanceServiceImpl-服务类
@服务 公共类InstanceServiceImpl实现InstanceService {
private InstanceRequest instanceRequest;
public InstanceServiceImpl(InstanceRequest instanceRequest) {
this.instanceRequest = instanceRequest;
}
}
Bean类:
包com.publicis.sapient.ppc.analyticstool.createec2instance.model;
公共类InstanceRequest {
private String description;
private String type;
private String storage;
private String userId;
private Integer projectId;
private Integer clientId;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getStorage() {
return storage;
}
public void setStorage(String storage) {
this.storage = storage;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public Integer getClientId() {
return clientId;
}
public void setClientId(Integer clientId) {
this.clientId = clientId;
}
}
Ec2Controller.java:
@RequestMapping(方法= RequestMethod.POST,值=“ / instances”) public InstanceResponse addInstance(@RequestBody InstanceRequest instanceRequest){
logger.info("propertyUrlDb : " + propertyUrlDb);
String email = instanceRequest.getUserId();
logger.info("Email id of the user : " + email);
String instanceId = null;
State state = new State();
InstanceServiceImpl instanceServiceImpl = new InstanceServiceImpl(instanceRequest);