Auditing with spring-data-mongodb

rohit :

I am trying to enable auto audit fields with spring data mongodb as explained here. Below is my configuration class

@ComponentScan(basePackages = "")
@EnableMongoRepositories(basePackages = "")
public class ApplicationConfiguration {

    public MongoDbFactory mongoDbFactory() throws Exception {
        ServerAddress serverAddress = new ServerAddress("", 27017);
        MongoCredential mongoCredential = MongoCredential.createCredential("user", "test", "abc123".toCharArray());
        MongoClient mongoClient = new MongoClient(serverAddress, Arrays.asList(mongoCredential));
        return new SimpleMongoDbFactory(mongoClient, "test");

    public MongoTemplate mongoTemplate() throws Exception {
        return new MongoTemplate(mongoDbFactory());

But when I add @EnableMongoAuditing, I am getting the below error on starting the server.

Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoAuditingHandler': Cannot create inner bean '(inner bean)#6dca0c34' of type [$MongoMappingContextLookup] while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#6dca0c34': Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type [] found for dependency []: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [] found for dependency []: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$
Arpit Aggarwal :

Can you check if you have Spring Data MongoDB dependency 1.9.4.RELEASE or above as mongoAuditingHandler requires MappingMongoConverter which is available in version 1.9.4.RELEASE or above as per changelog - spring-data-mongodb-changelog, for example:


Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at


Login to comment


Spring data mongodb auditing not working.. (Java config)

Count in Spring Data MongoDB repository

How to use Auditing in JPA/Spring-Data JPA?

Annotation based Auditing for spring-data-elasticsearch?

Spring Mongo Auditing not working @CreatedDate @CreatedBy

Spring Data JPA Auditing not working for the JpaRepository update method with @Modifying annotation, why?

Spring Data MongoDB nosql injection

Spring data for mongodb-3.6.0

Field based auditing with Spring

How to configure Auditing via Java Config in Spring Data (and Spring Data Rest)?

Auditing and @Embedded in Spring Data JPA

spring data mongodb group by

data auditing in Cassandra

Spring data mongodb not closing mongodb connections

Spring Data MongoDB failed with "in" query

How can I leverage spring-data-jpa auditing (AuditorAware) in asynchronous tasks?

Spring MongoDB Data elemMatch Simple

Spring Boot and JOOQ Auditing Solutions

spring data mongodb embeded query

Spring data - MongoDB - $regex search

@EnableMongoAuditing and @CreatedDate Auditing not working in Spring Boot 2.4.3

Spring JPA Auditing not updating rows

Disable spring boot auditing in a jhipster generated application

Spring Data Neo4j and Spring Data Auditing

Spring Data MongoDB <mongo:auditing/> cause IllegalArgumentException: Unsupported entity Could not determine IsNewStrategy

mongodb auditing in spring boot for saving createdDate, lastModifiedDate, createdBy, lastModifiedBy

SortBy Spring Data MongoDb

MongoDB Project and Group operations with Spring Data MongoDB

Reduce in Spring data mongodb