额外的未知端点被添加到 spring 启动应用程序

Extra Unknown endpoints getting added to spring boot application

我正在创建一个 spring 启动应用程序。我正在向它添加几个端点。在该过程中,一些端点是安全的,而另一些则不是。

安装应用程序后,我将获得一些额外的端点,这些端点提供甚至没有公开的应用程序信息。

示例: 一些暴露的端点是

@RestController
@RequestMapping("/category/v1")
public class ControllerClass {
     @RequestMapping(value="/pillars", method=RequestMethod.GET)
     public String pillarGetMethod() {
       //method
     }

     @RequestMapping(value="/frameworks", method=RequestMethod.GET)
     public String frameworkGetMethod() {
       //method
     }
}

现在期望我们会有

应该曝光。

但是

也因

的响应而暴露
{
  "_embedded" : {
    "pillars" : [ {

    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://<ip>/pillars{?page,size,sort}",
      "templated" : true
    },
    "profile" : {
      "href" : "http://<ip>/profile/pillars"
    },
    "search" : {
      "href" : "http://<ip>/pillars/search"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 5,
    "totalPages" : 1,
    "number" : 0
  }
}

我需要帮助来理解输出以及如何阻止它被暴露。

我猜你是这样定义的:

public class PillarRepository extends CrudRepository<Pillar, String> { ... }

public class FrameworkPillarRepository extends CrudRepository<Pillar, String> { ... }

如果是这样,基础资源将由 Spring Boot/Spring Data Rest 自动公开,除非您使用 @RepositoryRestResource(exported = false).

注释存储库

如果您只想重现自动 GET 行为,但使用自定义路径,请使用 path 选项。