需要在 Spring Boot 属性文件中配置 AWS 区域



现有代码:

public class AWSConfiguration
{
@Autowired
PropertyConfig property;
public AmazonSQS getSqs()
{
return AmazonSQSClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(getBasicAWSCredentials()))
.withRegion(Regions.US_WEST_2)
.build();
}
}

我想从属性文件配置区域 说:在应用程序属性文件中

awsRegion=us-west-2

并在现有代码中使用此属性

public AmazonSQS getSqs()
{
return AmazonSQSClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(getBasicAWSCredentials()))
.withRegion({fetch from property file})
.build();
}

在解决方案中找到

@Value("${doormls.awsRegion}")
private String regionSQS;
public AmazonSQS getSqs()
{
return AmazonSQSClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(getBasicAWSCredentials()))
.withRegion(Regions.fromName(regionSQS))
.build();
}

相关内容

  • 没有找到相关文章

最新更新