mongodb - 为什么 Postman 和 mongoDb db.getCollectionNames 返回空数组?
问题描述
我有一个连接到本地 mongoDB 数据库的 Spring Boot 应用程序。当我尝试从集合中获取所有记录时,它返回一个空数组。
Facture.class
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "Facture")
public class Facture {
@Id
private Long id_facture;
private int num_facture;
private double prix;
private String methode_paiement;
资料库
import com.app.Model.Facture;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface FactureDao extends MongoRepository<Facture, Long> {
}
邮递员结果
{
"timestamp": "2020-03-25T00:56:13.597+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/api/v1/all"
}
解决方案
答案是应该将 id 类型更改为 String 就可以了
推荐阅读
- sql - 了解 MVC SQL 查询。从,在哪里,然后选择
- java - 413 上传多部分文件时请求实体太大
- regex - 从 .yml 文件中 grep 特定值
- networking - 如何在 Ubuntu 中删除 SCTP 数据包中的“IPv4 地址参数”字段(可选)
- python - 使用 Adam 优化器在 FashionMNIST 上训练逻辑回归时出错
- sql - 填充桥表
- python - djnoer 给出 TypeError: permission_denied() got an unexpected keyword argument 'code' on get request on /users/me/
- laravel - 如何获取 id 以在控制器 laravel 中的另一个函数中使用
- python - 读取 pg_dump 文件发生在打开文件时
- r - R 中是否有代码可以根据其他标准区分同一列中的两个类别之间的差异?