【问题标题】:How to add AwsS3Client to spring boot project如何将 AwsS3Client 添加到 Spring Boot 项目
【发布时间】:2021-04-10 02:35:11
【问题描述】:

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

【问题讨论】:

  • 将这些依赖项直接添加到您的 pom 或 gradle 构建文件中?

标签: java spring spring-boot spring-cloud spring-cloud-aws


【解决方案1】:

您可以在项目中包含以下依赖项,即 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>

【讨论】:

  • 但是这些依赖在最新版的spring cloud中在哪里呢?
【解决方案2】:

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

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-aws</artifactId>
                <version>2.2.5.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-aws</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-aws-messaging</artifactId>
    </dependency>
    <dependency> 
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>    <!-- test is optional, it is based on your requirements -->
</dependencies>

【讨论】:

    猜你喜欢
    • 2023-04-09
    • 2021-09-26
    • 2021-04-01
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-24
    相关资源
    最近更新 更多