Member-only story

Data Auditing Using JaVers and Spring Data MongoDB

Eric Anicet
6 min readMar 11, 2024

In this story, we’ll see how to use JaVers in a simple Spring Boot app and MongoDB environment to track changes.

· Prerequisites
· Overview
What is JaVers
Why use JaVers
· Spring Boot Project Set-up
JaVers Dependencies
JaversRepository Configuration
Code implementation
· Testing
· Author Provider
· Retrieving Audit Information From JaVers Snapshots Repository
· Conclusion
· References

Prerequisites

This is the list of all the prerequisites:

  • Spring Boot 3+
  • Maven 3.6.+
  • Java 17 or later
  • MongoDB instance installed

Overview

What is JaVers

JaVers is a lightweight, fully open-source Java library for auditing changes in application data.

The usage of this tool is not limited to debugging and auditing only. It can be successfully applied to perform analysis, force security policies, and maintain the event log.

Why use JaVers

  • It’s open-source and free to use.
  • Configuration is easy.
  • It is compatible with traditional relational database systems and NoSQL systems. This makes migration between RDBMS and NoSQL much smoother.
  • Easy integration with Spring and Spring Boot.

Spring Boot Project Set-up

We will start by creating a simple Spring Boot project from start.spring.io, with the following dependencies: Spring Web, Spring Data MongoDB, Lombok, and Validation.

JaVers Dependencies

To integrate JaVers into our application, we must add the JaVers Spring Boot starter dependency in the project’s build.gradle or pom.xml file.

<dependency>
<groupId>org.javers</groupId>

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response