如何解决Spring-swagger模糊映射?

如何解决Spring-swagger模糊映射?,spring,spring-boot,swagger,swagger-ui,Spring,Spring Boot,Swagger,Swagger Ui,在我的spring控制器类中,我有以下两种方法 @GetMapping(value = "/published_messages", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> handleEmptyQueryParam() throws Exception { return ResponseEntity.status(HttpStatus.BAD

在我的spring控制器类中,我有以下两种方法

@GetMapping(value = "/published_messages", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<String> handleEmptyQueryParam() throws Exception
    {
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid Request , No Request Param received in the request");
    }

    @GetMapping(value = "/published_messages", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<String> getEdiDetailsByusername(@RequestParam(required=false, value="username") String username) throws Exception
    {
        List<String> userList = userService.getUserList(username);
        return isAValidResponse(userList);
    }
有人能建议在这种情况下

我在rest控制器中遵循和执行的任何操作都是正确的,而且在spring中也可以这样做,那么为什么大摇大摆地给出错误呢

Note : I got the answer , we need to use params attribute in the @GetMapping , it solved my issue .

Thanks to all .

不久前,我在演示过程中创建演示应用程序时遇到了类似的错误。出现此问题的原因是,在我的一个端点映射(例如,其他@GetMapping)中,我使用了“name”而不是“value”属性,因此问题可能出现在您未提供的代码部分

为什么要映射两个具有相同值的GET方法@GetMapping(value=“/published\u messages”是Spring给了你错误,而不是招摇过市。正如Rahul所说,你的映射是相同的。对于给定的url
/published\u messages
应该选择这两种方法中的哪种方法?@RahulVashishta,我只需要为不同的方法使用一个url映射,它将使用不同的参数,比如一个取name,另一个取emailid,你是c吗将此视为搜索API
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.4.0'
    compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.4.0'
Note : I got the answer , we need to use params attribute in the @GetMapping , it solved my issue .

Thanks to all .