当前位置: 首页 > 软件库 > Web应用开发 > >

spring-cloud-aws

授权协议 Apache-2.0 License
开发语言 Java
所属分类 Web应用开发
软件类型 开源软件
地区 不详
投 递 者 贡正诚
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Spring Cloud for Amazon Web Services

Spring Cloud for Amazon Web Services, part of the Spring Cloud umbrella project, eases the integration with hosted Amazon Web Services. It offers a convenient way to interact with AWS provided services using well-known Spring idioms and APIs, such as the messaging or caching API. Developers can build their application around the hosted services without having to care about infrastructure or maintenance.

Note: Further Spring Cloud AWS versions development moved to awspring/spring-cloud-aws. The only active branch in this repository is 2.2.x.

Checking out and building

To check out the project and build it from source, do the following:

git clone https://github.com/spring-cloud/spring-cloud-aws.git
cd spring-cloud-aws
mvn package

If you encounter out of memory errors during the build, increaseavailable heap and permgen for Maven:

MAVEN_OPTS='-XX:MaxPermSize=258m -Xmx1024m'

To build and install jars into your local Maven cache:

mvn install

Building documentation

Documentation can be built by activating the `docs`profile in the mavenbuild. If there is an ruby error like

LoadError: no such file to load -- asciidoctor

then the user must install the asciidoctor gem and set the environmentvariable `GEM_HOME`to the ruby gem folder. For example:

# Get gem info
  gem environment

  export GEM_HOME=<PATH FOR GEM ENVIRONMENT>

Using IntelliJ IDEA

Spring Cloud AWS development is done withIntelliJ IDEA. In order to create allIntelliJ IDEA project files, you have toimport the file within idea as a maven project.

Note: Please make sure to revert all changes in the .idea config filedirectory, as the maven plugin overwrites the configuration files keptin the scm.

Running integration tests

Spring Cloud AWS contains a test-suite which runs integration tests toensure compatibility with the Amazon Web Services. In order to run theintegration tests, the build process has to create different resourceson the Amazon Webservice platform (Amazon EC2 instances, Amazon RDSinstances, Amazon S3 Buckets, Amazon SQS Queues). Creating theseresources takes time and costs money, because every instance creation ischarged with a one hour usage. Therefore Spring Cloud AWS does notexecute the integration tests by default.

In order to run integration tests you must prepare three properties named accessKey,secretKey and rdsPassword. These twoproperties accessKey and secretKey are account/user specific and shouldnever be shared to anyone. To retrieve these settings you have to openyour account inside the AWS console and retrieve them through theSecurityCredentials Page. Note: In general we recommend that you use anAmazon IAM user instead of the accountitself. The last password rdsPassword is used to access the databaseinside the integration tests. This password has a minimum length of 8characters.

Also you must prepare the sender and recipient mail addresses to test theAmazon Simple E-Mail Service. These twoaddresses must be verified for the Amazon SES Service.

To build with the integration tests you must execute

mvn verify -Daws-integration-tests.access-key=<access key>  -Daws-integration-tests.secret-key=<secret key> -DrdsPassword=<rds password> -DsenderAddress=<sender address> -DrecipientAddress=<recipient address>

The integration test will create anAmazon Web ServicesCloudFormation stack and execute the tests. The stack is destroyedafter executing the tests (either successful or failed) to ensure thatthere are no unnecessary costs.

Costs of integration tests

The costs for one integration test run should not be more than 0.40 $per hour (excl. VAT).

Developing using Amazon Web Services

During development it might be time-consuming to run the integrationtests regularly. In order to create a stack only once, and reuse themfor the tests run, you have to create the stack manually using thetemplate found in /spring-cloud-aws-integration-test/src/test/resources.You will need to create the stack with the name "IntegrationTestStack"to ensure that the integration tests will re-use the stack.

Getting in touch

Spring Cloud Team on Twitter

Individual team members can be found on different social media channels

Contributing

Spring Cloud is released under the non-restrictive Apache 2.0 license,and follows a very standard Github development process, using Githubtracker for issues and merging pull requests into master. If you wantto contribute even something trivial please do not hesitate, butfollow the guidelines below.

Sign the Contributor License Agreement

Before we accept a non-trivial patch or pull request we will need you to sign theContributor License Agreement.Signing the contributor’s agreement does not grant anyone commit rights to the mainrepository, but it does mean that we can accept your contributions, and you will get anauthor credit if we do. Active contributors might be asked to join the core team, andgiven the ability to merge pull requests.

Code of Conduct

This project adheres to the Contributor Covenant code ofconduct. By participating, you are expected to uphold this code. Please reportunacceptable behavior to spring-code-of-conduct@pivotal.io.

Code Conventions and Housekeeping

None of these is essential for a pull request, but they will all help. They can also beadded after the original pull request but before a merge.

  • Use the Spring Framework code format conventions. If you use Eclipseyou can import formatter settings using theeclipse-code-formatter.xml file from theSpringCloud Build project. If using IntelliJ, you can use theEclipse Code FormatterPlugin to import the same file.

  • Make sure all new .java files to have a simple Javadoc class comment with at least an@author tag identifying you, and preferably at least a paragraph on what the class isfor.

  • Add the ASF license header comment to all new .java files (copy from existing filesin the project)

  • Add yourself as an @author to the .java files that you modify substantially (morethan cosmetic changes).

  • Add some Javadocs and, if you change the namespace, some XSD doc elements.

  • A few unit tests would help a lot as well — someone has to do it.

  • If no-one else is using your branch, please rebase it against the current master (orother target branch in the main project).

  • When writing a commit message please follow these conventions,if you are fixing an existing issue please add Fixes gh-XXXX at the end of the commitmessage (where XXXX is the issue number).

Checkstyle

Spring Cloud Build comes with a set of checkstyle rules. You can find them in the spring-cloud-build-tools module. The most notable files under the module are:

spring-cloud-build-tools/
└── src
    ├── checkstyle
    │   └── checkstyle-suppressions.xml (3)
    └── main
        └── resources
            ├── checkstyle-header.txt (2)
            └── checkstyle.xml (1)
  1. Default Checkstyle rules

  2. File header setup

  3. Default suppression rules

Checkstyle configuration

Checkstyle rules are disabled by default. To add checkstyle to your project just define the following properties and plugins.

pom.xml
<properties>
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError> (1)
        <maven-checkstyle-plugin.failsOnViolation>true
        </maven-checkstyle-plugin.failsOnViolation> (2)
        <maven-checkstyle-plugin.includeTestSourceDirectory>true
        </maven-checkstyle-plugin.includeTestSourceDirectory> (3)
</properties>

<build>
        <plugins>
            <plugin> (4)
                <groupId>io.spring.javaformat</groupId>
                <artifactId>spring-javaformat-maven-plugin</artifactId>
            </plugin>
            <plugin> (5)
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
        </plugins>

    <reporting>
        <plugins>
            <plugin> (5)
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>
</build>
  1. Fails the build upon Checkstyle errors

  2. Fails the build upon Checkstyle violations

  3. Checkstyle analyzes also the test sources

  4. Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules

  5. Add checkstyle plugin to your build and reporting phases

If you need to suppress some rules (e.g. line length needs to be longer), then it’s enough for you to define a file under ${project.root}/src/checkstyle/checkstyle-suppressions.xml with your suppressions. Example:

projectRoot/src/checkstyle/checkstyle-suppresions.xml
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
		"-//Puppy Crawl//DTD Suppressions 1.1//EN"
		"https://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
	<suppress files=".*ConfigServerApplication\.java" checks="HideUtilityClassConstructor"/>
	<suppress files=".*ConfigClientWatch\.java" checks="LineLengthCheck"/>
</suppressions>

It’s advisable to copy the ${spring-cloud-build.rootFolder}/.editorconfig and ${spring-cloud-build.rootFolder}/.springformat to your project. That way, some default formatting rules will be applied. You can do so by running this script:

$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig
$ touch .springformat

IDE setup

Intellij IDEA

In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin.The following files can be found in the Spring Cloud Build project.

spring-cloud-build-tools/
└── src
    ├── checkstyle
    │   └── checkstyle-suppressions.xml (3)
    └── main
        └── resources
            ├── checkstyle-header.txt (2)
            ├── checkstyle.xml (1)
            └── intellij
                ├── Intellij_Project_Defaults.xml (4)
                └── Intellij_Spring_Boot_Java_Conventions.xml (5)
  1. Default Checkstyle rules

  2. File header setup

  3. Default suppression rules

  4. Project defaults for Intellij that apply most of Checkstyle rules

  5. Project style conventions for Intellij that apply most of Checkstyle rules

Code style
Figure 1. Code style

Go to FileSettingsEditorCode style. There click on the icon next to the Scheme section. There, click on the Import Scheme value and pick the Intellij IDEA code style XML option. Import the spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml file.

Code style
Figure 2. Inspection profiles

Go to FileSettingsEditorInspections. There click on the icon next to the Profile section. There, click on the Import Profile and import the spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml file.

Checkstyle

To have Intellij work with Checkstyle, you have to install the Checkstyle plugin. It’s advisable to also install the Assertions2Assertj to automatically convert the JUnit assertions

Checkstyle

Go to FileSettingsOther settingsCheckstyle. There click on the + icon in the Configuration file section. There, you’ll have to define where the checkstyle rules should be picked from. In the image above, we’ve picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build’s GitHub repository (e.g. for the checkstyle.xml : https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml). We need to provide the following variables:

Important
Remember to set the Scan Scope to All sources since we apply checkstyle rules for production and test sources.
  • 英文原文:https://spring.io/projects/spring-cloud-aws 目录 概述 特性 基于注解的SQS队列侦听器 基于注解的SNS监听器  消息模板 快速开始 学习 文档 示例 概述 Spring Cloud for Amazon Web Services是Spring Cloud项目的一部分,可以简化与托管Amazon Web Services的集成。它提供了一种使

  • mvn clean命令,报错如下: [INFO] Scanning for projects… [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/cloud/spring-cloud-commons-dependencies/1.2.2.RELEASE/spring-c

  • Spring Cloud 是一个基于 Spring Framework 实现的云原生应用开发工具包,它提供了一系列开箱即用的分布式系统开发工具和服务,用于构建可伸缩、高可用、弹性的云原生应用。 以下是 Spring Cloud 的一些核心组件: Eureka:服务注册与发现组件,支持高可用部署。 Ribbon:负载均衡组件,支持多种负载均衡策略。 Feign:RESTful 服务客户端,支持声明式

  • 公司最近用minio 生产环境也使用支持S3协议的存储服务。spring cloud aws 就支持S3协议。 第一步引入相关jar包 <dependency> <groupId>io.awspring.cloud</groupId> <artifactId>spring-cloud-aws-dependencies</artifactId> <version>2.3.2<

  • java 启动方法如下 package com.example.product; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netfl

  • Spring-Cloud的版本是如何定义的   Spring Cloud是一个由众多独立子项目组成的大型综合项目,每个子项目有不同的发行节奏,都维护着自己的发布版本号。Spring Cloud通过一个资源清单BOM(Bill of Materials)来管理每个版本的子项目清单。为避免与子项目的发布号混淆,所以没有采用版本号的方式,而是通过命名的方式。   这些版本名称的命名方式采用了伦敦地铁站的

  • spring boot/cloud 项目中,看到如下配置: <parent> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-parent</artifactId> <version>Edgware.SR3</version>

 相关资料
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智能路由,微代理,控制总线)。分布式系统的协调导致了样板模式, 使用Spring Cloud开发人员可以快速地支持实现这些模式的服务和应用程序。他们将在任何分布式环境中运行良好,包括开发人员自己的笔记本电脑,裸机数据中心,以及Cloud Foundry等托管平台。

  • Spring Cloud 为开发人员提供了工具,以快速构建分布式系统中的某些常见模式(例如:配置管理、服务发现、智能路由、微代理、控制总线、一次性令牌、全局锁、分布式会话、群集状态等)。分布式系统的协调导致了样板式样,并且使用Spring Cloud开发人员可以快速站起来实现这些样板的服务和应用程序。它们可以在任何分布式环境中正常工作,包括开发人员自己的笔记本电脑,裸机数据中心以及Cloud Fo

  • Cloudfoundry的Spring Cloud可以轻松地在Cloud Foundry(平台即服务)中运行 Spring Cloud应用程序 。Cloud Foundry有一个“服务”的概念,它是“绑定”到应用程序的中间件,本质上为其提供包含凭据的环境变量(例如,用于服务的位置和用户名)。 spring-cloud-cloudfoundry-web项目为Cloud Foundry中的webapp

  • 我们最近从Spring Cloud Netflix Ribbon迁移到Spring Cloud LoadBalancer,并使用Spring Cloud kubernetes作为发现客户端。 现在spring.cloud.kubernetes.ribbon.mode(https://cloud.spring.io/spring-cloud-static/spring-cloud-kubernete

  • 主要内容:Spring Cloud Config,Spring Cloud Config 工作原理,Spring Cloud Config 的特点,搭建 Config 服务端,搭建 Config 客户端,手动刷新配置,Config+Bus 实现配置的动态刷新在分布式微服务系统中,几乎所有服务的运行都离不开配置文件的支持,这些配置文件通常由各个服务自行管理,以 properties 或 yml 格式保存在各个微服务的类路径下,例如 application.properties 或 applicat

  • 主要内容:API 网关,Spring Cloud Gateway ,Gateway 的工作流程,Predicate 断言,Spring Cloud Gateway 动态路由,Filter 过滤器在微服务架构中,一个系统往往由多个微服务组成,而这些服务可能部署在不同机房、不同地区、不同域名下。这种情况下,客户端(例如浏览器、手机、软件工具等)想要直接请求这些服务,就需要知道它们具体的地址信息,例如 IP 地址、端口号等。 这种客户端直接请求服务的方式存在以下问题: 当服务数量众多时,客户端需要维护