This article presents Javers, an open-source Java library, enabling comprehensive and temporal auditing and versioning of entities in Java applications. It simplifies tracking changes to objects, offering historical versions and insights into data mo
To use Javers for entity change tracking, follow these steps:
<code class="xml"><dependency> <groupId>com.googlecode.javers</groupId> <artifactId>javers-core</artifactId> <version>6.2.3</version> </dependency></code>
<code class="java">Javers javers = JaversBuilder.javers().build();</code>
<code class="java">javers.register(Author.class); javers.register(Book.class);</code>
<code class="java">Book book = new Book("The Hitchhiker's Guide to the Galaxy", "Douglas Adams"); Entity audit = javers.commit("default", book);</code>
<code class="java">book.setName("The Restaurant at the End of the Universe"); javers.commit("default", book);</code>
<code class="java">List<Change> changes = javers.findChanges(JaversQuery.byInstance(book).build());</code>
Using Javers for auditing and versioning offers several benefits:
Yes, Javers can be integrated with various frameworks and databases. Here are some examples:
javers-persistence
module.javers-persistence
module.javers-mongo
module.javers-neo4j
javers-mongo
module.🎜🎜🎜Neo4j:🎜 Javers can be integrated with Neo4j using the javers-neo4j
module.🎜🎜The above is the detailed content of javers usage tutorial. For more information, please follow other related articles on the PHP Chinese website!