【问题标题】:why Postman and mongoDb db.getCollectionNames return empty array?为什么 Postman 和 mongoDb db.getCollectionNames 返回空数组?
【发布时间】:2020-07-05 13:42:38
【问题描述】:

我有一个连接到本地 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;

FactureRepository

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"
}

【问题讨论】:

    标签: mongodb spring-boot rest api postman


    【解决方案1】:

    答案是应该将 id 类型更改为 String,这样就可以了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-17
      • 2019-11-23
      • 2018-12-19
      • 2019-02-14
      • 2012-10-22
      • 1970-01-01
      • 2021-11-16
      • 2018-01-16
      相关资源
      最近更新 更多