SpringBoot 使用 swagger 实现Rest Api 文档化

SpringBoot实践(十三):集成swagger-ui展示接口 后端的Rest请求列表响应和描述信息在前后端协同开发时至关重要,swagger-ui能够通过配置无侵入地展示接口路径,描述,传参信息等,其集成非常简单,也有其他更优的第三方swagger-ui前端; 目录 pom.xml 配置类 application.properties controller UI效果 pom.xml 增加swagger和ui包依赖; <dependency> <groupId>io.springfox</groupId> 阅读详情

swagger 允许用户在一个html5 web 页面中,对API 进行文档化和交互
优点:
功能丰富 :支持多种注解,自动生成接口文档界面,支持在界面测试API接口功能;
及时更新 :开发过程中花一点写注释的时间,就可以及时的更新API文档,省心省力;
整合简单 :通过添加pom依赖和简单配置,内嵌于应用中就可同时发布API接口文档界面,不需要部署独立服务。

实现 swagger 文档

  1. 添加依赖
    主要是 添加 swagger2 核心包 以及 swagger-ui界面包 的依赖
      <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.7.0</version>
        </dependency>
  1. 配置 api 页面的基本信息
/**
 * Created by Sean on 2018/10/10
 *Api 文档页面 基本信息
 * 可以通过注解注入相关配置。
 * 通过这些配置可以指定在spring-boot启动时扫描哪些controller层的文件夹,
 * 另外可以指定API文档页的标题和描述信息等内容
 * @author Sean
 */
@Configuration
@EnableSwagger2
public class Swagger2 {


    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.voicecyber"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title(" RESTful APIs")
                .description(" Rest  Server api接口文档")
                .version("1.0")
                .build();
    }
}
  1. 将swagger-ui 暴露到spring boot环境 主要是配置spring mvc 的一些资源拦截
/**
 * Created by Sean on 2018/10/10
 *将swagger-ui中的界面配置至spring-boot环境
 * @author Sean
 */
@Component
public class WebMvcConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/js/");
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}
  1. 在controller 中编写自己的api 文档 主要在于参数,和接口的描述
@Api(value = "RestApi", description = "Rest Api Server")
@RestController
@RequestMapping("api")
public class RestApiController {
    /**
     *需要注意的是  必须指定 RequestMethod  的具体类型,不然前端会显示多种类型的Rest
     */
    @ApiOperation(value = "信息总览", notes = "用户信息总览")
    @ApiImplicitParam(name = "type", value = "获取信息的类型(name ,sex)", paramType = "query", dataType = "string")
    @RequestMapping(value = "info", method = RequestMethod.GET)
    @ResponseBody
    public ResponseEntity getUserInfo(String type) {
        System.out.println(type);
        return new ResponseEntity("this is user info ", HttpStatus.OK);
    }
   }
  1. .配置properties 文件
    这个文件配置非常重要 ,主要在于
    springfox.documentation.swagger.v2.host 的配置非常重要,在访问的swagger-ui.html 页面时。如果访问的路径不统一,那么可能会发生跨域的问题
springfox.documentation.swagger.v2.host=127.0.0.1:8080
springfox.documentation.swagger.v2.path=/api
server.port=8080
server.context-path=/rest
  1. 访问页面
    使用上面的host 路径 再加上 swagger-ui.html 即可访问页面http://127.0.0.1:8080/swagger-ui.html
    github url:springbootrestswagger
如何把spring boot应用发布到Harbor 主要介绍了如何把spring boot应用发布到Harbor,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 立即下载

相关推荐

APK静态分析(取证角度)——理论部分

APP是指应用程序(Application),是指能够在手机、平板电脑、电脑等移动设备上运行的软件。APP可以帮助用户进行各种功能操作,如社交媒体、游戏、购物、学习、工作等。用户可以通过应用商店或者在线下载安装APP,然后在设备上使用它们。APP的种类非常丰富,能够满足用户不同的需求和兴趣。

currify的博客 3206

springBoot整合harbor

【代码】springBoot整合harbor。

qq_41551345的博客 708

华为OD机试_2025 B卷_模拟消息队列(Python,100分)(附详细解题思路)

时间排序:确保事件处理顺序正确消费者管理:集合操作高效维护状态优先级实现:利用消费者ID自然排序边界处理:正确处理空消费者情况。

测试工程师的成长之路 1117

Harbor 2.0 API JAVA版本调用demo

全网搜索了下Harbor 2.0 API,几乎全是Linux curl或者python版本,java版本的很少,至少我找到的没调用成功,因为工作需要,将jar包或者前端静态文件制作成docker镜像。腾讯TKE并未提供这种支持,历经一番手动传输到VM再用linux命令上传,完全是拼体力。为了解决这种低效率问题,我写了个web版本的工具用来替代繁琐的手动敲命令制作、上传镜像。 1、核心Maven 依赖 <dependencies> <dependency>

kakahu2015的博客 2744

Python-Opencv中的膨胀和腐蚀

Python-Opencv中的膨胀和腐蚀 腐蚀和膨胀是对白色部分(高亮部分)而言的,不是黑色部分。 膨胀就是图像中的高亮部分进行膨胀,“邻域扩张”,效果图拥有比原图更大的高亮区域。腐蚀就是原图中高亮部分被腐蚀,“邻域被蚕食”,效果图拥有比原图更小的高亮区域。 1.膨胀 膨胀过程是有一个结构元素或者模板去在原图像素比对,当比对过程中,中心像素位置的值根据其八邻域取或运算,或运算为1就取自己的中心值,...

qq_44262417的博客 1万+

CANoe软件之离线报文回放与分析实战

本文详细介绍了如何使用CANoe软件进行离线报文回放与分析,帮助工程师将现场故障数据转化为可反复研究的实验室资源。通过实战步骤,指导如何搭建分析工程、加载DBC文件解码信号,并利用Trace和Graphics窗口进行深度数据筛选与图形化分析,从而高效定位汽车电子故障,是提升诊断效率的关键技能。

weixin_29227585的博客 527

OPENAPI3.0 与 SpringBoot 开发实战: 新型高效开发模式,实现代码与API分离,高效开发,开发必看!!!

Open3.0 开发模式不仅仅是对于开发来说,对于整个公司都是有利的,开发的api逻辑清晰,前端对接高效,每个字段都有注释统一的result api风格,对外提供api更加便捷

码小呆的博客 1万+

S4HANA Rebate Management(条件合同) -Single Step

S4HANA 条件合同管理(Condition Contract Management), 包括如何创建条件合同,场景应用

m0_50200150的博客 2306

springboot集成springdoc-openapi(模拟前端请求)

springdoc-openapi使用`@io.swagger.v3.oas.annotations`包下的注解来定义API文档,它遵循OpenAPI规范,并提供了一些额外的注解来进行更细粒度的控制。springdoc-openapi-ui中间已经包含了swagger也就是说,使用springdoc-openapi-ui是可以替代的。- springdoc-openapi通常只需要引入`springdoc-openapi-ui`依赖,并且不需要太多的配置即可生成和展示OpenAPI文档。

比起日出,我更喜欢日落。我的意思是比起遇见你,我更喜欢与你终老 8849

用PyTorch实战清华SSVEP数据集:手把手教你搭建第一个脑机接口分类模型(附完整代码)

本文详细介绍了如何使用PyTorch实战清华大学SSVEP数据集,从数据预处理到CNN模型构建的全流程。通过手把手教学,帮助读者搭建第一个脑机接口分类模型,特别针对数据维度转换等关键难点提供可视化解析,并附完整代码实现。

weixin_42566121的博客 348

Linux服务器上后台运行jupyter notebook/Lab

1 安装配置教程2 后台运行jupyter3 更改运行环境kernel4 SSH端口转发 1 安装配置教程 可以参考:https://www.cnblogs.com/thousfeet/p/10647102.html 2 后台运行jupyter screen -S jupyter # 新建一个名为jupyter的后台screen # 在base环境下,先 cd 到指定文件目录 jupyter notebook # or jupyter lab 3 更改运行环境kernel 需要手动为每个环境添加内.

strivequeen的博客 1834

Spring Boot 整合 springdoc-openapi

SpringDoc学习笔记

坚持学习永不言弃 9156

Hermes Agent 常见报错排查与问题解决

Hermes Agent 常见报错排查指南 摘要 本文全面梳理了 Hermes Agent 使用过程中的10类常见报错,按阶段划分为安装期、运行期认证类、后端基础设施类和长任务执行类四大类,并提供了系统化的排查流程: 安装期问题:包括命令未找到和Python版本不兼容,主要检查PATH环境和Python版本是否符合要求 认证类问题:涉及API Key认证失败和速率限制,需要验证密钥配置和配额状态 基础设施问题:包含Docker报错、MCP连接失败和OAuth令牌过期,需检查相关服务状态 执行类问题:主要是上

简简单单Onlinezuozuo 1343

SpringBoot 3 与 SpringDoc 打造完美接口文档

SpringDoc 是一个开源工具,它集成了 OpenAPI 3 和 Swagger UI,可以自动为基于 Spring Boot 开发的 REST API 生成 API 文档。SpringDoc 替代了过去的 SpringFox,并提供了与 SpringBoot 3 更好的兼容性。@Schema(description = "错误响应")@Schema(description = "HTTP状态码", example = "404")

yk_dflkg的博客 2271

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

SpringBoot实战:如何通过代理服务器访问华为NCE北向REST接口

本文详细介绍了在受限网络环境下,如何通过SpringBoot构建HTTP代理网关来安全访问华为NCE北向REST接口的工程实践。文章提供了完整的开发教程,涵盖架构设计、核心代码实现、SSL证书处理、Swagger UI集成以及生产环境部署的安全与性能考量,为开发者解决网络隔离下的系统集成难题提供了可靠方案。

fern8的博客 1068

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

从原理到代码:深入理解AE算法中Shutter与Frame Length的联动机制

本文深入解析了自动曝光(AE)算法中Shutter(曝光时间)与Frame Length(帧长度)的核心联动机制。从CMOS传感器滚动快门的工作原理出发,阐述了在光线变化时,为保障画面亮度而增加Shutter会导致Frame Length被迫延长,进而造成帧率下降的根源。文章通过Pline Table设计、帧率平滑策略及实战代码,提供了优化AE算法、平衡画质与流畅度的系统性解决方案。

c2d3e4f的博客 541

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

SpringBoot 和 SpringCloud 微服务实用指南(二)

一个 API(如 RESTful 服务)的价值在很大程度上取决于它是多么容易消费!良好且易于访问的文档是 API 是否有用的一个重要因素。在本章中,我们将学习如何使用 OpenAPI/Swagger 来文档化我们可以从微服务架构中外部访问的 API。正如我们在第二章,《Spring Boot 简介》中提到的,Swagger 是文档 RESTful 服务时最常用的规范之一,许多领先的 API 网关都有对 Swagger 的本地支持。我们将学习如何使用 SpringFox 生成此类文档,以及使用 SpringF

龙哥盟 588

如何有效地使用SprinBoot框架来创建微服务应用程序呢?

开发人员可以通过向Jetty服务器添加新的依赖项来更改默认的Web容器。 org.springframework.boot spring-boot-starter-jetty </ dependency 自定义配置文件 快速创建应用程序并且无须很大的工作量,这两者对于开发人员来说其实是一回事,但同样重要的是能够轻松自定义和覆盖默认设置。在这一方面,Spring Boot可以派上用场,提供支持配置管理的机制。要自定义配置,最简单的方法是使用配置文件,然后将配置文件追加到应用程序胖JAR。Spring

m0_65484838的博客 238

构建RESTfulAPI的SpringBoot秘籍

资源应使用名词表示,如`/users`而非`/getUsers`。创建控制器类时,使用`@RestController`注解(它是`@Controller`和`@ResponseBody`的组合)。使用`@ControllerAdvice`和`@ExceptionHandler`注解。在实体类上添加验证注解,如`@NotNull`、`@Size`等。通过`/actuator/health`端点可以查看应用健康状态,`/actuator/metrics`获取性能指标。对于大量数据的场景,实现分页和排序功能。

searchboy2025的博客 20

Swagger给返回参数添加注释说明

处理效果 第一步,控制层加上注解 @ApiResponses({ @ApiResponse(code = 200,message = "OK",response = TrainUserTEntity.class), }) 第二步,实体类属性上面加上注解 @ApiModelProperty(value = "姓名", required = true) ...

qq_25983579的博客 5万+

Java全栈开发面试实战:从基础到项目落地的深度探讨

Autowired。

CatchLight的博客 354

Swagger2在springboot中的使用

一、在pom.xml添加如下maven依赖 <!--swagger2包--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> .

zk86547462的博客 484

从Java全栈到前端框架:一次真实面试中的技术探索

通过这次面试,我们可以看到,一个优秀的Java全栈开发者不仅需要掌握后端技术,还需要熟悉前端框架和相关工具链。从Java语言、JVM原理、Spring Boot框架到Vue3、Element Plus组件库,再到REST API设计和消息队列的使用,每一个环节都至关重要。对于初学者来说,建议从基础入手,逐步深入。比如先掌握Java语法和面向对象编程,再学习Spring Boot框架,接着接触前端技术如Vue3和Element Plus,最后深入了解REST API设计和消息队列的使用。

CatchLight的博客 142

springboot集成swagger3.0.0

在pom.xml文件添加相关依赖 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency>--> 2.创建配置.

cyzyt520520的博客 1795

精通 Spring5(三)

让我们创建一个自定义异常,并从服务中抛出它。super(msg);这是一个非常简单的代码片段,定义了。现在让我们增强我们的类,当找不到具有给定 ID 的todo时抛出如果返回一个空的todo,我们抛出。当我们向一个不存在的todo)发送一个GET正如我们所看到的,清晰的异常响应被发送回服务使用者。然而,还有一件事情可以进一步改进——响应状态。当找不到资源时,建议返回404 - 资源未找到状态。我们将在下一个示例中看看如何自定义响应状态。

龙哥盟 394

SpringBoot+Swagger不显示对象和字段备注遇到的大坑

错误是成功的先导 ---------- Banana.Banuit Gang(香柚帮) 使用Swagger生成接口文档,已确定注解什么的都写了,但是文档中就是不会出现对象和字段的注释,网上也查找了各种原因,尝试了各种方法,始终不行,几乎绝望了,所有的对象都是如此。 经过坚持不懈的搞来搞去,最后不知道脑子怎么想的,改了一个地方,终于好了。。。 //原本对象上注解写法 @ApiModel(value="com.banuit.hd.screenpe.dao.model.HdTvBp",descript

@Banana的博客 7277
上一篇: Spring Boot rest api 返回 XML 格式的数据
下一篇: Spring Boot 单文件,多文件上传,以及将文件写入响应中
Sean_zzZ
博客等级 码龄10年 18粉丝 105原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值