0
A
回答
2
您也可以下載AWS Java SDK的here。這也是在Maven倉庫:
Maven的:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.9.7</version>
</dependency>
搖籃:
'com.amazonaws:aws-java-sdk:1.9.7'
現在,到使用SDK。你可能想在getting started with the aws sdk.
讀了下面是一些非常淡化代碼,讓你開始:
import com.amazonaws.services.elasticbeanstalk.AWSElasticBeanstalkClient;
import com.amazonaws.services.elasticbeanstalk.model.*;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.PutObjectRequest;
import java.io.File;
public class AwsTest {
public static void main(String[] args) {
AWSElasticBeanstalkClient eb = new AWSElasticBeanstalkClient();
// Create Application
CreateApplicationRequest request = new CreateApplicationRequest("myAppName");
eb.createApplication(request);
// Create Environment
CreateEnvironmentRequest envRequest = new CreateEnvironmentRequest("myAppName", "env-name");
envRequest.setSolutionStackName("64bit Amazon Linux 2014.09 v1.0.9 running Tomcat 7 Java 7");
envRequest.setVersionLabel("application Version");
eb.createEnvironment(envRequest);
// Deploy code
CreateStorageLocationResult location = eb.createStorageLocation();
String bucket = location.getS3Bucket();
File file = new File("myapp.zip");
PutObjectRequest object = new PutObjectRequest(bucket, "myapp.zip", file);
new AmazonS3Client().putObject(object);
CreateApplicationVersionRequest versionRequest = new CreateApplicationVersionRequest();
versionRequest.setVersionLabel("myversion");
versionRequest.setApplicationName("myAppName");
S3Location s3 = new S3Location(bucket, "myapp.zip");
versionRequest.setSourceBundle(s3);
UpdateEnvironmentRequest updateRequest = new UpdateEnvironmentRequest();
updateRequest.setVersionLabel("myversion");
eb.updateEnvironment(updateRequest);
}
}
0
部署AWS Elastic Beanstalk環境的便捷方法是使用AWS Toolkit for Eclipse。
它允許您在本地編寫和測試代碼,然後創建Elastic Beanstalk環境並將您的代碼部署到環境中。
Elastic Beanstalk管理控制檯也可用於使用示例應用程序部署Java環境,然後您可以用自己的代碼覆蓋該示例應用程序。
參見:
0
有本條所指的一小段代碼,在上面給出的代碼丟失,
CreateApplicationVersionRequest versionRequest = new CreateApplicationVersionRequest();
versionRequest.setVersionLabel("myversion");
versionRequest.setApplicationName("myAppName");
S3Location s3 = new S3Location(bucket, "myapp.zip");
versionRequest.setSourceBundle(s3);
您需要新增eb.createApplicationVersion(versionRequest);
以創建包含自己的源文件的新版本。只有這樣您才能將新版本部署到環境的運行實例。
相關問題
- 1. AWS Elastic Beanstalk,創建環境失敗
- 2. 無法在AWS Elastic Beanstalk中創建環境?
- 3. AWS Elastic Beanstalk Python:如何配置環境以使用硒?
- 4. AWS Elastic Beanstalk:如何在ebextensions中使用環境變量?
- 5. 如何使用CloudFormation將域名別名到Elastic Beanstalk環境?
- 6. 使用現有資源創建Elastic Beanstalk環境
- 7. Elastic beanstalk - 使用現有安全組創建環境
- 8. 通過JAVA API向AWS Elastic Beanstalk環境部署新戰役
- 9. 如何爲環境創建Elastic Beanstalk配置模板
- 10. AWS Elastic Beanstalk和JAVA_OPTS
- 11. AWS + Elastic Beanstalk + MongoDB
- 12. 如何在AWS中使用Plotly Python SDK Elastic Beanstalk
- 13. 如何使用AWS Python SDK等待Elastic Beanstalk事件Boto 3
- 14. AWS Elastic Beanstalk緩存?
- 15. AWS SDK | Elastic Beanstalk的服務員名單
- 16. 如何在使用awscli創建Elastic Beanstalk環境時選擇EC2實例類型?
- 17. 在Amazon AWS上存儲應用程序Elastic Beanstalk環境
- 18. 如何在AWS Elastic Beanstalk中的多個grails環境中使用單個.war?
- 19. Elastic Beanstalk環境的名稱是否可用作環境變量?
- 20. AWS EB CLI(elastic beanstalk)
- 21. Node.js deploy - AWS Elastic Beanstalk
- 22. AWS elastic beanstalk + Nginx + Gunicorn
- 23. 在aws中的相同環境中的Nodejs和php Elastic beanstalk
- 24. AWS Elastic Beanstalk和SQS
- 25. AWS Elastic Beanstalk - 針對不同環境的單獨配置
- 26. AWS Elastic Beanstalk和Composer
- 27. AWS Elastic Beanstalk:命令eb列表不顯示環境
- 28. AWS Elastic Beanstalk問題
- 29. 在一個AWS EC2實例(Elastic Beanstalk)上運行多個環境
- 30. AWS Elastic Beanstalk - 使用Mongodb代替使用Python和Django環境的RDS
您是否嘗試創建環境並使用java代碼進行部署,或者您是否嘗試以任何方式將java代碼部署到環境中? – 2014-11-25 18:13:16