mongodb - Spring Boot API 响应的变化
问题描述
我有一个 Spring Boot 应用程序,其中 Mongodb 作为数据库,Jenkins 作为 CI 服务器。这是 Jenkins 存储的数据示例:
{
"_id" : ObjectId("60ed8d8482cd350a2cd9db28"),
"buildId" : "35",
"wokspace" : "/var/lib/jenkins/workspace/ACM-JENKINS-API",
"remoteUrl" : "http://172.16.4.105:7990/scm/jenkins/acm-jenkins-api.git",
"branch" : "origin/branch-youssef",
"type" : "back",
"date" : "2021-07-13 14:56:36",
"description" : "Démarré par l'utilisateur Youssef Boudaya",
"backupPath" : "/root/backups_api/backup_35",
"projectId" : "60ed8d6a24ac0a5cee63aafe"
}
这是 API 响应:
{
"id": "60ed8d8482cd350a2cd9db28",
"build_id": "35",
"workspace": null,
"remote_url": "http://172.16.4.105:7990/scm/jenkins/acm-jenkins-api.git",
"branch": "origin/branch-youssef",
"description": "Démarré par l'utilisateur Youssef Boudaya",
"type": "back",
"date": "2021-07-13 14:56:36",
"project_id": "60ed8d6a24ac0a5cee63aafe",
"backup_path": "/root/backups_api/backup_35"
}
我想知道为什么列名有所不同。我在 Spring Boot 中的实体:
/** The id. */
private String id;
/** The build id. */
// Build id de jenkins
private String buildId;
/** The workspace. */
private String workspace;
/** The remote url. */
private String remoteUrl;
/** The branch. */
private String branch;
/** The description. */
private String description;
/** The type. */
private String type;
/** The date. */
private String date;
/** The project id. */
private String projectId;
/** The backup path. */
private String backupPath;
并且 DTO 具有模型类的确切结构。
解决方案
Spring boot Entites Members 将大写字母转换为列名中的下划线。我的意思是 myName 将是数据库中的 my_name 这是行为
推荐阅读
- java - How can i use two buttons in setOnDragListener?
- ios - 如何使滚动视图滚动*和*同时满足不同尺寸设备的约束
- javascript - Angular6 Recursive List Drag and Drop CDK
- android - 当我的应用程序进行电池优化时,为什么我无法收到推送通知?
- javascript - 如何在wordpress中隐藏或隐藏下载链接,如果直接复制粘贴则不允许访问?
- java - while 循环返回随机数而不是字符串
- html - 主线程上来自 HTML 的 NSAttributedString 的行为就像多线程一样
- node.js - 为什么我的本地主机没有为 node.js 加载?
- html - 是否有可能证明文本区域中的文本
- batch-file - 如何列出/播放 :C\music 目录中的所有音乐