首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring cloud aws set端点

Spring cloud aws set端点
EN

Stack Overflow用户
提问于 2018-07-09 04:01:21
回答 2查看 1.8K关注 0票数 5

我在openStack中使用Spring cloud AWS连接到我亚马逊S3,默认情况下,端点是s3.amasonaws.com,我想更改端点,因为我的存储桶S3我们在私有云中,而不是在公共云中。

代码语言:javascript
复制
 <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-aws</artifactId>
 </dependency>

。。。。

代码语言:javascript
复制
<dependencyManagement>
 <dependencies>
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-dependencies</artifactId>
    <version>${spring-cloud.version}</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
 </dependencies>
</dependencyManagement>

……在我的application.properties

代码语言:javascript
复制
cloud.aws.stack.auto=false
cloud.aws.region.static=eu-west-3
storage.s3.accessKey=AKIAJNGI4VX4DTY4U24Q

想着你的帮助。

EN

回答 2

Stack Overflow用户

发布于 2019-11-29 04:44:22

在我的机器上本地配置了S3的情况下,我尝试使用LocalStack时遇到了类似的问题。由于Spring Boot没有配置端点的选项,因此我们必须自己定义bean。然后,我们只需使用新定义的bean。

代码语言:javascript
复制
/**
 * It must be configured, if we need to upload a file using the LocakStack configuration.
 * Because of it, we must define a new client since the default one has not an option to configure the Endpoint.
 *
 * @see org.springframework.cloud.aws.context.config.annotation.ContextResourceLoaderConfiguration.Registrar#registerBeanDefinitions(AnnotationMetadata, BeanDefinitionRegistry)
 */
@Bean(name = "amazonS3Client")
public AmazonS3 amazonS3Client(AWSCredentialsProvider credentialsProvider,
                               RegionProvider regionProvider,
                               @Value("${aws.s3.default-endpoint:https://s3.amazonaws.com}") String endpoint) {

    return AmazonS3ClientBuilder.standard()
        .withCredentials(credentialsProvider)
        .withEndpointConfiguration(
            new AwsClientBuilder.EndpointConfiguration(endpoint, regionProvider.getRegion().getName()))
        .build();
}
票数 2
EN

Stack Overflow用户

发布于 2021-09-01 17:57:54

可以使用cloud.aws.s3.endpoint属性重写终结点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51235554

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档