JAVA-929: Migrate spring-cloud-aws to parent-boot-2 (#9230)
* JAVA-929: Migrate spring-cloud-aws to parent-boot-2 * JAVA-929: Corrected Live Tests * JAVA-929: Updated README
This commit is contained in:
parent
7d3591ae2b
commit
93074cdabc
|
@ -23,7 +23,6 @@ Let's say that the RDS instance is called `spring-cloud-test-db` having the mast
|
|||
to write the following in `application.properties`:
|
||||
|
||||
```
|
||||
cloud.aws.rds.spring-cloud-test-db
|
||||
cloud.aws.rds.spring-cloud-test-db.password=se3retpass
|
||||
```
|
||||
Multiple application classes are available under this project. To launch InstanceProfileAwsApplication application, replace `start-class` under `pom.xml`:
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -43,6 +43,12 @@
|
|||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -60,7 +66,7 @@
|
|||
<properties>
|
||||
<start-class>com.baeldung.spring.cloud.aws.SpringCloudAwsApplication</start-class>
|
||||
<spring-cloud.version>Dalston.SR4</spring-cloud.version>
|
||||
<spring-cloud>2.0.1.RELEASE</spring-cloud>
|
||||
<spring-cloud>2.2.1.RELEASE</spring-cloud>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
package com.baeldung.spring.cloud.aws.s3;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.WritableResource;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -14,14 +7,29 @@ import java.io.OutputStream;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.aws.core.io.s3.PathMatchingSimpleStorageResourcePatternResolver;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.WritableResource;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
|
||||
@Component
|
||||
public class SpringCloudS3 {
|
||||
|
||||
@Autowired
|
||||
ResourceLoader resourceLoader;
|
||||
|
||||
private ResourcePatternResolver resourcePatternResolver;
|
||||
|
||||
@Autowired
|
||||
ResourcePatternResolver resourcePatternResolver;
|
||||
public void setupResolver(ApplicationContext applicationContext, AmazonS3 amazonS3) {
|
||||
this.resourcePatternResolver = new PathMatchingSimpleStorageResourcePatternResolver(amazonS3, applicationContext);
|
||||
}
|
||||
|
||||
public void downloadS3Object(String s3Url) throws IOException {
|
||||
Resource resource = resourceLoader.getResource(s3Url);
|
||||
|
|
|
@ -2,7 +2,6 @@ cloud.aws.credentials.accessKey=YourAccessKey
|
|||
cloud.aws.credentials.secretKey=YourSecretKey
|
||||
cloud.aws.region.static=us-east-1
|
||||
|
||||
cloud.aws.rds.spring-cloud-test-db
|
||||
cloud.aws.rds.spring-cloud-test-db.password=se3retpass
|
||||
|
||||
# These 3 properties are optional
|
||||
|
|
Loading…
Reference in New Issue