This is a demo springboot application created using IntelliJ Spring Initialzr which will show case basic CRUD and Automatic CSFLE (Client Side Field Level Encryption) with MongoDB Atlas.
This demo connects to MongoDB Atlas using a Java Spring Boot Application with Personal Identifiable Information (PII) data automatically encrypted before sending it to the database.
- Java 11
- Spring boot 2.7.10
- Spring Data MongoDB
- MongoDB Atlas
- Maven
- Get started with a Free Tier Cluster on MongoDB Atlas.
- Read this blog post: Quick Start - Getting your Free MongoDB Atlas Cluster.
- Create a file
src/main/resources/mongodb.properties
and add the following entries:- MongoDB URI
spring.data.mongodb.uri
- database
spring.data.mongodb.database
- collection
spring.data.mongodb.collection
- path to your mongo_crypt_shared library
crypt.shared.lib.path
- MongoDB URI
Then you can run as a Spring Boot Application or just run the class JavaSpringBootCSFLEApplication.java
.
- Start the server in a console with
mvn spring-boot:run
. - If you add some Unit Tests, you would start them with
mvn clean test
. - You can build the project with
mvn clean package
.
Use at your own risk; not a supported MongoDB product.
- Megha Arora @ MongoDB.