Java 昂首阔步(-ui)不';不显示操作

Java 昂首阔步(-ui)不';不显示操作,java,spring,operation,swagger,swagger-ui,Java,Spring,Operation,Swagger,Swagger Ui,我有一个SpringWebApp,我添加了一个招摇过市的ui。我添加了一个虚拟类来测试swagger: import com.wordnik.swagger.annotations.Api; import com.wordnik.swagger.annotations.ApiError; import com.wordnik.swagger.annotations.ApiErrors; import com.wordnik.swagger.annotations.ApiOperation; im

我有一个SpringWebApp,我添加了一个招摇过市的ui。我添加了一个虚拟类来测试swagger:

import com.wordnik.swagger.annotations.Api; import com.wordnik.swagger.annotations.ApiError; import com.wordnik.swagger.annotations.ApiErrors; import com.wordnik.swagger.annotations.ApiOperation; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Api(value = "DummyController", description = "Dummy description for the controller") @Controller @RequestMapping(value = "/dummy") public class DummyClassForSwagger { @ApiOperation(value = "First dummy output", httpMethod = "GET") @ApiErrors({@ApiError(code = 404, reason = "First dummy test") }) @RequestMapping(value = "/first", method = RequestMethod.GET) @ResponseBody public String dummyOutputOne() { return "Dummy output"; } @ApiOperation(value = "Second dummy output", httpMethod = "GET") @ApiErrors({@ApiError(code = 404, reason = "Second dummy test") }) @RequestMapping(value = "/second", method = RequestMethod.GET) @ResponseBody public String dummyOutputTwo() { return "Second dummy output"; } }
我想,问题是缺少标签“操作”或类似的东西……但我不确定(我不知道,如何修复)。有什么建议吗?

我也有类似的问题。我收到错误
“Swagger操作HandleAllegalArgumentsException缺少方法。”

调试后,我发现
Controller
类中的
@ExceptionHandler
方法没有任何
swagger
注释,这就是问题的根源

我对我的
ExceptionHandler
方法进行了注释,然后swagger ui开始正常工作

我现在正在弄清楚SpringMVC中的
ExceptionHandler
方法要使用哪些招摇过市的注释

我的控制器类中的
ExceptionHandler
方法是:

@ExceptionHandler({IllegalArgumentException.class})
public ResponseEntity<?> handleIllegalArgumentsException(IllegalArgumentException e)
{
    LOGGER.error("IllegalArgumentException in user controller", e);
    return new ResponseEntity<>(new ErrorResponseDTO("BAD_REQUEST", e.getMessage()), HttpStatus.BAD_REQUEST);
}
@ExceptionHandler({IllegalArgumentException.class})
公共响应HandleAllegalArgumentSexception(IllegalArgumentException e)
{
LOGGER.error(“用户控制器中的IllegalArgumentException”,e);
返回新的ResponseEntity(新的ErrorResponseDTO(“错误的请求”,例如getMessage()),HttpStatus.BAD的请求);
}

我遇到了一个类似的问题,我通过以下方式解决了它:
@ExceptionHandler({IllegalArgumentException.class})
public ResponseEntity<?> handleIllegalArgumentsException(IllegalArgumentException e)
{
    LOGGER.error("IllegalArgumentException in user controller", e);
    return new ResponseEntity<>(new ErrorResponseDTO("BAD_REQUEST", e.getMessage()), HttpStatus.BAD_REQUEST);
}