← All tutorials

GoCareerGo Tutorials

MongoDB Tutorial

Documents, collections, CRUD, aggregation, Atlas and driver connectivity.

Connecting from Spring Boot

spring-boot-starter-data-mongodb gives you repository-style access to MongoDB, the same pattern Spring Data JPA uses for SQL.

public interface UserRepository extends MongoRepository<User, String> {
    List<User> findByCity(String city);
}
spring.data.mongodb.uri=mongodb://localhost:27017/shop