public|JeecgBoot与MongoDB集成实战文档( 二 )


}
@GetMapping("/test2")
public Result<?> TestMongoDb2(){
repository.deleteAll();
// save a couple of customers
repository.save(new Customer("Alice", "Smith"));
repository.save(new Customer("Bob", "Smith"));
// fetch all customers
System.out.println("Customers found with findAll():");
System.out.println("-------------------------------");
for (Customer customer : repository.findAll()) {
System.out.println(customer);
}
System.out.println();
// fetch an individual customer
System.out.println("Customer found with findByFirstName('Alice'):");
System.out.println("--------------------------------");
System.out.println(repository.findByFirstName("Alice"));
System.out.println("Customers found with findByLastName('Smith'):");
System.out.println("--------------------------------");
for (Customer customer : repository.findByLastName("Smith")) {
System.out.println(customer);
}
return Result.OK("存入成功");
}
}
6. 测试结果测试后的数据库截图
public|JeecgBoot与MongoDB集成实战文档
文章图片

public|JeecgBoot与MongoDB集成实战文档
文章图片

public|JeecgBoot与MongoDB集成实战文档
文章图片

【public|JeecgBoot与MongoDB集成实战文档】本文转载自:https://blog.csdn.net/u013473447/article/details/121902906

推荐阅读