Whether you are a long-time user or just getting started with data auditing, we want to hear from you. Javers is evolving toward an Open Core model and will be offering Professional Support soon. Your insights are more valuable than ever.
Contact us.

Getting started

All JaVers artifacts are published to Maven Central.

Spring Boot Starters

The easiest and strongly recommended way to start with Javers is adding one of our Spring Boot starters to your project dependencies.

If you are using MongoDB — add this dependency:

Gradle:
implementation 'org.javers:javers-spring-boot-starter-mongo:7.10.0'

Maven:
<dependency> 
    <groupId>org.javers</groupId>
        <artifactId>javers-spring-boot-starter-mongo</artifactId>
    <version>7.10.0</version>
</dependency>

If you are using an SQL database:

Gradle:
implementation 'org.javers:javers-spring-boot-starter-sql:7.10.0'

Maven:
<dependency>
        <groupId>org.javers</groupId>
        <artifactId>javers-spring-boot-starter-sql</artifactId>
        <version>7.10.0</version>
</dependency>

Please note that Javers 7.10+ is compatible with Spring Boot 4, so all Javers Spring integration modules require Java 17.

Javers Spring Boot starters integrate seamlessly with your existing Spring Boot configuration. They provide sensible defaults and automatically create the Javers instance as a Spring bean. You can start using Javers immediately with little to no additional configuration.

Read more about Javers’ Spring Boot integration and Javers’ Spring integration.

Tutorials and Articles

  • [Baeldung] Intro to JaVers
    Teaser: This article, written by Eugen Baeldung, serves as a starting point for understanding JaVers. It provides an overview of JaVers’ core feature — the Object Diff. It covers comparing objects, collections, and object graphs.

  • [Baeldung] Using JaVers for Data Model Auditing in Spring Data
    Teaser: This Baeldung tutorial covers the JaVers Data Audit feature in depth. It shows how to integrate JaVers with Spring Data JPA to automate entity change tracking with minimal configuration. The article provides concrete examples of auditing repositories using @JaversSpringDataAuditable and @JaversAuditable, as well as managing transactions. It also explains JQL queries for retrieving historical data as Snapshots (state maps), Changes (atomic differences), or Shadows (reconstructed domain objects).

  • [JaVers Blog] JaVers vs Envers Comparison
    Teaser: If you are debating between JaVers and Hibernate Envers, this article is essential reading. It provides a detailed technical breakdown of the object-oriented approach used by JaVers versus the table-oriented model of Envers, highlighting the benefits of technology independence.

  • JaVers: Code Audit Logs Easily in Java
    Teaser: This article provides a comprehensive guide to implementing Data Audit trail using JaVers and Spring Boot. It describes the JaVers table structure for SQL repositories, specifically detailing how the JV_COMMIT table stores metadata like the author and commit date, while the JV_SNAPSHOT table stores the object’s state as JSON. The article includes examples of versioning nested Value Objects (like EmailAddress lists), showing how JaVers creates separate snapshots for each object. Furthermore, it demonstrates querying for nested objects using the DEEP_PLUS Shadow scope to reconstruct full historical object graphs.

Vanilla Javers

If you are not using Spring, add javers-core to your project dependencies and (optionally) choose proper javers-repository module.

javers-core

Gradle:

implementation 'org.javers:javers-core:7.10.0'

Please note that Javers core and Javers persistence modules require Java 11.

If you’re going to use JaVers as an object diff tool, this is the only dependency you need.

javers-repository

If you are going to use JaVers as a data audit framework, choose the proper repository implementation. For example, if you’re using MongoDB add:

Gradle:

implementation 'org.javers:javers-persistence-mongo:7.10.0'

If you are using an SQL database — add:

implementation 'org.javers:javers-persistence-sql:7.10.0'

Create a JaVers instance

Use JaversBuilder to create a JaVers instance:

import org.javers.core.Javers;
import org.javers.core.JaversBuilder;
//...
Javers javers = JaversBuilder.javers().build();

Now, the JaVers instance is up and ready, configured with reasonable defaults. Good enough to start.

Later on, you would probably need to refine the configuration and introduce some basic facts about your domain model to JaVers.

Object diff

Use the compare() method to calculate a diff for two arbitrary complex domain objects:

Person tommyOld = new Person("tommy", "Tommy Smart");
Person tommyNew = new Person("tommy", "Tommy C. Smart");

Diff diff = javers.compare(tommyOld, tommyNew);

See more diff examples.

Data audit

Use the javers.commit() method to audit changes done on your domain objects. Javers saves subsequent versions of domain objects as Snapshots in JaversRepository

Person robert = new Person("bob", "Robert Martin");
javers.commit("user", robert);

See more audit examples.

Auto-audit aspects

To automatically audit objects saved to your repositories, use the JaVers auto-audit aspect annotations. For example, apply @JaversSpringDataAuditable to Spring Data repositories:

@JaversSpringDataAuditable
public interface PersonRepository extends CrudRepository<Person, String> {
}

Read more about the Auto-audit aspects.

JaVers logo small
Open source Java library available under Apache License