This is a minimal example of using Amazon S3 in a Spring Boot application. It demonstrates how to integrate Amazon S3 functionality with Spring Boot, using a local Minio instance as the S3 service.
- Simple Spring Boot application integrated with Amazon S3 using Minio.
- Uses H2 database for local storage.
- Configurable via
docker-composefor easy setup and testing.
- Dockerfile: Defines the container image for the Spring Boot application.
- test-docker-compose.yml: Defines services for the Spring Boot app and Minio.
- Spring Boot dependencies: Includes necessary dependencies for AWS SDK, JPA, H2, Lombok, and MapStruct.
git clone https://github.com/panic08/amazon-s3-spring-boot-example.git
cd amazon-s3-spring-boot-exampledocker-compose -f test-docker-compose.yml up --buildThis command will build and start the Spring Boot application along with the Minio service.
-
Spring Boot app: Available at http://localhost:9000
-
Minio S3 console: Available at http://localhost:9001
- Username:
minioadmin - Password:
minioadmin
- Username:
You can customize the application settings such as AWS region, access keys, and endpoints by modifying the environment variables in the test-docker-compose.yml file:
AWS_S3_REGION: Set to your desired AWS region (default:us-east-1).AWS_S3_ACCESS_KEYandAWS_S3_SECRET_KEY: Set to your Minio credentials.AWS_S3_ENDPOINT: Set the endpoint for Minio (default:http://minio:9000).
The project includes the following dependencies:
spring-boot-starter-data-jpaspring-boot-starter-websoftware.amazon.awssdk:s3lombokmapstructh2database
You can add additional dependencies as needed for your use case.
The project includes tests based on spring-boot-starter-test and can be executed using the following command:
./mvnw test