当前位置: 首页 > 知识库问答 >
问题:

Spring Data Rest-隐藏而不是公开ID

都飞跃
2023-03-14

我有一个entity类,它有一个映射为@ID的自然ID字段,而我没有任何代理ID(仅为表ID发明的字段)字段。并且,在Jackson编组的JSON中,我看到了一个额外的id

所以不是:

{
    "bin":"123456", ...
}
{
    "id":"123456", "bin":"123456", ...
}
@Entity
@Data
@Table(name="bin_info")
public class BinInfo implements Serializable, Persistable<String> {
    @Id
    @NotBlank //this is for absent parameter. Not equal to Pattern regex check
    @Pattern(regexp = "^\\d{6,8}$") //6-8 digits
    @Column(name="bin")
    @JsonProperty("bin")
    private String bin;

    ...

我支持这些依赖:

dependencies {
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-aop')
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-data-rest')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-undertow')
    runtime('com.h2database:h2')
    runtime('org.postgresql:postgresql')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('io.cucumber:cucumber-java:3.0.2')
    testCompile('io.cucumber:cucumber-junit:3.0.2')
    testCompile('io.cucumber:cucumber-spring:3.0.2')
}

Spring Boot 2.0.3。

共有1个答案

邓光耀
2023-03-14

尝试使用@naturalid而不是@id进行批注。

 类似资料:
  • 问题内容: 我正在尝试使用灯箱时禁用父级的html / body滚动条。这里的主要词是 disable 。我也 没有 想隐藏它。 这样做的原因是使站点跳转并占据了滚动条所在的区域。 我想知道是否有可能在仍然显示它的同时禁用滚动条。 问题答案: 如果覆盖层下的页面可以在顶部“固定”,则在打开覆盖层时可以设置 您仍应看到右侧的滚动条,但内容不可滚动。当您关闭叠加层时,只需还原这些属性即可 我之所以这样

  • 问题:如果距离为空/null,我试图隐藏一个值。 我尝试了以下操作,但该值仍在显示: 和 什么是实现我所期待的正确方法。 以下是我在coldfusion中定义距离的方式: 当我做以下建议时: ng-show="e.distance===未定义" 当我执行其他建议时,例如ng hide=“e.distance”, 以下是提供商包含的内容:

  • 我尝试了和。我还尝试了。它只会禁用菜单项,但我需要完全隐藏它(因此它甚至不应该显示为该项分配的空间)。 为了隐藏菜单项,我可以对XML进行哪些更改?

  • 我需要隐藏控制台窗口,我很快通过P/Invoking ShowWindow解决了这个问题。但是,调用隐藏了控制台窗口以及控制台窗口的任务栏按钮。我需要任务栏按钮保持可见。但是,我没有寻找最小化控制台窗口的方法。单击任务栏按钮显示不做任何事情。我尝试使用SetWinEventHook并在每次激活时隐藏窗口,但没有用,因为调用此函数的窗口必须运行消息循环才能接收事件(我的控制台窗口没有,无论我设置了O

  • 我有一个AAR库,它依赖于某个。我在AAR中添加了以下内容: 在生成的AAR中,我仍然可以访问中的类。基于SO中的许多答案,关键字应该防止这种情况发生。我错过了什么吗?

  • 如果我想在不同的结构上使用相同的解决方案,比如dl dt模块而不是表,该怎么办?我将如何构造JQuery代码以显示所选产品的标签? 我尝试了多种方法来显示最近的标签,但都没有效果。 请参阅要演示的代码段。 我尝试使用JQuery隐藏未选择的标签,但找不到有选择地显示活动选择的方法。 null null