如何将 AwsS3Client 添加到 Spring Boot 项目

问题描述

我正在使用 Spring Boot 2.4.1Spring Cloud 2020.0.0,但我找不到 spring-cloud-starterspring-cloud-starter-awsspring-cloud-aws-messaging 这个 starter 在哪里?
如何将这些依赖项添加到我的项目中?
我需要在我的 spring-boot 项目中获得 AwsS3Client

解决方法

您可以将以下依赖项包含到您的项目中,即 pom.xml 文件。

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-aws</artifactId>
    <version>2.2.5.RELEASE</version>
</dependency>


<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-aws-messaging</artifactId>
    <version>2.2.5.RELEASE</version>
</dependency>
,

我假设您使用的是 maven,如果是这样,您可以在 pom.xml 文件中添加以下内容;

Connection conn = getConnection();
String str = new String("Bank «My Money»".getBytes(StandardCharsets.UTF_8));
Clob myClob = conn.createClob();
myClob.setString(1,str);

String res = myClob.getSubString(1,str.length());
System.out.println(res);