spring-aws-extras

Util classes to glue Spring and AWS together.

License

License

Categories

Categories

AWS Container PaaS Providers
GroupId

GroupId

se.solrike.spring-aws-extras
ArtifactId

ArtifactId

spring-aws-extras
Last Version

Last Version

0.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

spring-aws-extras
Util classes to glue Spring and AWS together.
Project URL

Project URL

https://github.com/Lucas3oo/spring-aws-extras
Source Code Management

Source Code Management

https://github.com/Lucas3oo/spring-aws-extras

Download spring-aws-extras

How to add to project

<!-- https://jarcasting.com/artifacts/se.solrike.spring-aws-extras/spring-aws-extras/ -->
<dependency>
    <groupId>se.solrike.spring-aws-extras</groupId>
    <artifactId>spring-aws-extras</artifactId>
    <version>0.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/se.solrike.spring-aws-extras/spring-aws-extras/
implementation 'se.solrike.spring-aws-extras:spring-aws-extras:0.0.4'
// https://jarcasting.com/artifacts/se.solrike.spring-aws-extras/spring-aws-extras/
implementation ("se.solrike.spring-aws-extras:spring-aws-extras:0.0.4")
'se.solrike.spring-aws-extras:spring-aws-extras:jar:0.0.4'
<dependency org="se.solrike.spring-aws-extras" name="spring-aws-extras" rev="0.0.4">
  <artifact name="spring-aws-extras" type="jar" />
</dependency>
@Grapes(
@Grab(group='se.solrike.spring-aws-extras', module='spring-aws-extras', version='0.0.4')
)
libraryDependencies += "se.solrike.spring-aws-extras" % "spring-aws-extras" % "0.0.4"
[se.solrike.spring-aws-extras/spring-aws-extras "0.0.4"]

Dependencies

compile (4)

Group / Artifact Type Version
com.amazonaws : aws-java-sdk-core jar 1.11.928
com.amazonaws : aws-java-sdk-s3 jar 1.11.928
org.springframework : spring-context jar 5.3.5
org.springframework : spring-core jar 5.3.5

runtime (2)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.30
io.awspring.cloud : spring-cloud-aws-core jar 2.3.0

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.7.0
org.mockito : mockito-core jar 3.7.7
org.mockito : mockito-junit-jupiter jar 3.7.7
org.springframework.boot : spring-boot-starter-test jar 2.4.4

Project Modules

There are no modules declared in this project.

spring-aws-extras

Util classes to glue Spring and AWS together.

For instance you can use Spring's ResourceLoader to load Java ResourceBundles located in an AWS S3 bucket.

To use it from Gradle depend on:

implementation 'se.solrike.spring-aws-extras:spring-aws-extras:0.0.4'

Version 0.0.3 work with Spring boot 2.3.x and Spring Cloud AWS 2.2.x.

Version 0.0.4 work with Spring boot 2.4.x and Spring Cloud AWS 2.3.x.

Code example on add S3 URL support to Spring's ResourceLoader. Import the S3ProtocolResolverConfiguration Spring configuration that will add an S3 protocol resolver to the application context. S3ProtocolResolverConfiguration only does it thing if AwsRegionCondition is true and it needs an AmazonS3 object.

@Configuration
@Import({ S3ProtocolResolverConfiguration.class })
public class TestConfigForS3Support {

  @Bean(name = "amazonS3")
  @Conditional(AwsRegionCondition.class)
  public AmazonS3 amazonS3() {
    return AmazonS3ClientBuilder.defaultClient();
  }

  /**
   * Call to this method must be after the S3 support has been added to the context/resource
   * loader
   */
  @Bean("someClass")
  @Primary
  @ConditionalOnBean(name = S3ProtocolResolverConfiguration.BEAN_NAME)
  @DependsOn(S3ProtocolResolverConfiguration.BEAN_NAME)
  public SomeClass someClassWithS3(ResourceLoader resourceLoaderWithS3) {
    return new SomeClass(resourceLoaderWithS3, true);
  }

  /**
   * Fallback if S3 is not available. I.e. we are not running with AWS config to access S3.
   */
  @Bean("someClass")
  public SomeClass someClassWithoutS3(ResourceLoader resourceLoader) {
    return new SomeClass(resourceLoader, false);
  }

}


Versions

Version
0.0.4
0.0.3
0.0.2
0.0.1