DLQ MongoTemplate could not be found

I used axon server in my application, i tried to configure the DLQ with mongodb, but this error

Parameter 0 of method deadLetterQueueConfigurerModule in AxonDLQConfig required a bean of type ‘org.axonframework.extensions.mongo.MongoTemplate’ that could not be found

I have this dependencies :

    <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-spring-boot-starter</artifactId>
        <version>4.7.2</version>
    </dependency>
    <dependency>
        <groupId>org.axonframework.extensions.reactor</groupId>
        <artifactId>axon-reactor-spring-boot-starter</artifactId>
        <version>4.7.0</version>
    </dependency>
    <dependency>
        <groupId>org.axonframework.extensions.mongo</groupId>
        <artifactId>axon-mongo</artifactId>
        <version>4.7.0</version>
    </dependency>

I configure the DLQ like below

@Bean
public ConfigurerModule deadLetterQueueConfigurerModule(org.axonframework.extensions.mongo.MongoTemplate mongoTemplate) {
    log.debug("##### Register DLQ for processingGroup {} #####", PROCESSING_GROUP);
    return configurer -> configurer.eventProcessing().registerDeadLetterQueue(
            PROCESSING_GROUP,
            config -> MongoSequencedDeadLetterQueue.builder()
                    .processingGroup(PROCESSING_GROUP)
                    .maxSequences(256)
                    .maxSequenceSize(256)
                    .mongoTemplate(mongoTemplate)
                    .transactionManager(config.getComponent(TransactionManager.class))
                    .serializer(config.serializer())
                    .build()
    ).registerDeadLetterPolicy(PROCESSING_GROUP, configuration -> (letter, cause) -> {
        Integer retries = (Integer) letter.diagnostics().getOrDefault("retries", 0);
        if (retries < MAX_RETRIES) {
            return Decisions.requeue(cause, l -> l.diagnostics().and("retries", retries + 1));
        }
        return Decisions.doNotEnqueue();
    });
}

You can do two things. Either define the Mongotemplate yourself, or change the axon-mongo dependency to axon-mongo-spring-boot-starter to have it setup for you.
Do you also use the Mongo token store or the Mongo saga store?
This is what the auto configuration will use:

    @Bean
    @ConditionalOnMissingBean
    public MongoTemplate axonMongoTemplate(MongoDatabaseFactory factory) {
        String databaseName = axonMongoProperties.getDatabaseName();
        if (isNull(databaseName)) {
            return SpringMongoTemplate.builder()
                                      .factory(factory)
                                      .build();
        } else {
            return SpringMongoTemplate.builder()
                                      .factory(factory)
                                      .databaseName(databaseName)
                                      .build();
        }
    }

When i change the axon-mongo dependency to axon-mongo-spring-boot-starter, i get this error:

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventhandling.tokenstore.TokenStore]: Factory method ‘tokenStore’ threw exception; nested exception is com.mongodb.MongoCommandException: Command failed with error 263 (OperationNotSupportedInTransaction): ‘Cannot run ‘createIndexes’ in a multi-document transaction.’ on server localhost:27017. The full response is {“operationTime”: {“$timestamp”: {“t”: 1677869229, “i”: 18}}, “ok”: 0.0, “errmsg”: “Cannot run ‘createIndexes’ in a multi-document transaction.”, “code”: 263, “codeName”: “OperationNotSupportedInTransaction”, “$clusterTime”: {“clusterTime”: {“$timestamp”: {“t”: 1677869229, “i”: 18}}, “signature”: {“hash”: {“$binary”: {“base64”: “AAAAAAAAAAAAAAAAAAAAAAAAAAA=”, “subType”: “00”}}, “keyId”: 0}}}

That depends on how you run mongo, since transactions are only supported for clusters. The easiest way around this for local is to use docker with something like this:

  mongodb:
    image: bitnami/mongodb:6.0.4
    ports:
      - "27017:27017"
    environment:
      - MONGODB_REPLICA_SET_MODE=primary
      - ALLOW_EMPTY_PASSWORD=yes