2017-09-25 79 views
0

我正在创建一个弹簧启动应用程序。我增加了几个端点。在这个过程中,一些端点是安全的,有些则不是。额外的未知端点被添加到弹簧启动应用程序

一旦安装了应用程序,我得到了一些额外的端点给予甚至没有暴露的应用程序信息。

举例: 一些暴露的端点是

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

现在期望是,我们将有

  • /分类/ V1 /支柱
  • /分类/ V1 /框架

应该暴露。

但与

  • /支柱
  • /框架

也越来越暴露出与响应,

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

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

+2

您是否定义了类似扩展CrudRepository的PillarRepository和Framework类?如果是这样,除非使用'@RepositoryRestResource(exported = false)'注解存储库,否则底层资源会自动暴露在Spring Boot/Spring Data Rest中。 –

+0

非常感谢@Marc。它解决了这个问题。请将答复添加为答案,我将非常乐意接受答案作为正确答案。 – Shaleen

回答

1

我的猜测是你定义是这样的:

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

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

如果是这样,底层资源由Spring启动/弹簧数据休息自动曝光,除非你@RepositoryRestResource(exported = false)注释库。

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

相关问题