我正在用Apache CXF构建Spring Boot应用程序。当尝试添加swagger时,我得到没有在规范中定义的操作!错误,尽管我通过注释1-2操作指定。Swagger的CXF配置部分如下:
factory.setFeatures(Collections.singletonList(createSwaggerFeature()));
public Swagger2Feature createSwaggerFeature() {
Swagger2Feature swagger2Feature = new Swagger2Feature();
swagger2Feature.setPrettyPrint(true);
swagger2Feature.setSupportSwaggerUi(true);
swagger2Feature.setScanAllResources(true);
swagger2Feature.setHost("localhost:8080");
swagger2Feature.setBasePath("/cxf/todo_list");
swagger2Feature.setTitle("TodoList Application");
swagger2Feature.setContact("https://www.github/abondar24");
swagger2Feature.setDescription("Another TodoList application with Spring Boot and Swagger");
swagger2Feature.setVersion("1.0.0");
return swagger2Feature;
}
我相信功能没有设置,correctly.What我错过了吗?api-docs的链接如下:http://localhost:8080/cxf/todo_list/api-docs?url=/cxf/todo_list/swagger.json
在UI页面的explore字段中: /cxf/todo_list/swagger.json
发布于 2017-10-05 22:03:21
我已经解决了这个问题。我忘了把@Path注解放到我的REST服务中。在我这么做之后,swagger开始工作了。我唯一不明白的是--如何摆脱默认标签
发布于 2021-08-11 16:46:40
我也有同样的问题,我通过修改控制器模块来修复它
在这里,我从@Controller
=>更改为@RestController
,并且它起作用了。
https://stackoverflow.com/questions/46508257
复制相似问题