MongoClientException occurs when using @Transactional annotation

◆Version information
MongoDB: MongoDB 5.0 (Standalone)
Java: JDK8
Spring: org.springframework.boot:spring-boot-starter-data-mongodb:2.7.18

◆QA
I am trying to use MongoDB’s transactional features.
I am trying to control transactions using 「@Transactional」annotation, but
The following Exception occurs when running the application.

[Exception]
com.mongodb.MongoClientException: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.

As a workaround, set the “spring.data.mongodb.uri parameter” in application.properties to
I added “?retryWrites=false” and re-run application.

[My configuration]
spring.data.mongodb.uri=mongodb://localhost:27017/local?retryWrites=false

However, the following exception occurred even when re-run application.

[Exception]
com.mongodb.MongoClientException: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.

I don’t know what causes this error, can you give me some help

Can you print the full stack trace (there should be a chained exception that has the complete server error) and share it?

What version of MongoDB are you running against, and what deployment type (standalone, replica set, or sharded)? Note that transactions are not supported on standalone deployments, and support for them began with MongoDB 4.0.

1 Like

Thank you for your reply.
MongoDB is using V5.0.
Also, this time I was trying to use transaction functionality with standalone MongoDB.
Since the transaction function is not supported in standalone,
I think I’ll give up on using the transaction function this time.