Posts

Showing posts with the label spring boot

How to connect AWS using spring boot example code

To connect to AWS using Spring Boot, you can use the AWS SDK for Java.   Here is an example code that shows how to connect to AWS using Spring Boot:   1. Add the AWS SDK dependency to your project. You can do this by adding the following to your pom.xml file: <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk</artifactId> <version>1.12.91</version> </dependency> 2. Configure the AWS credentials. You can either set the credentials as environment variables or use a profile file. Here's an example of setting the credentials as environment variables: export AWS_ACCESS_KEY_ID=<your-access-key> export AWS_SECRET_ACCESS_KEY=<your-secret-key> export AWS_REGION=<your-region> 3. Create an AWS client bean. In your Spring Boot application, create a bean for the AWS client that you want to use. For example, to create an S3 client, you can use the following code: @Configuration