ganchaoyang / spring-tutorial Goto Github PK
View Code? Open in Web Editor NEW本项目是我个人在编写Spring Boot系列博客的源代码,会持续不断更新。如果项目中的代码有错误,望大家一起勘正~。
Home Page: https://itweknow.cn
本项目是我个人在编写Spring Boot系列博客的源代码,会持续不断更新。如果项目中的代码有错误,望大家一起勘正~。
Home Page: https://itweknow.cn
看完博主的那篇关于spring boot整合swagger文档的博客,觉得博主写得实在通俗易懂,可以允许我搬运到csdn上吗?转载的那种
本篇文章种有一部分讲述有关自定义响应消息的代码如下
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, newArrayList(
new ResponseMessageBuilder()
.code(500)
.message("服务器发生异常")
.responseModel(new ModelRef("Error"))
.build(),
new ResponseMessageBuilder()
.code(403)
.message("资源不可用")
.build()
));
如果直接复制,会报以下错误。
Cannot resolve constructor 'ArrayList(springfox.documentation.service.ResponseMessage, springfox.documentation.service.ResponseMessage)'
应该是ArrayList的初始化问题
我做了如下修改
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, new ArrayList() {{
add(new ResponseMessageBuilder()
.code(500)
.message("服务器发生异常")
.responseModel(new ModelRef("Error"))
.build());
add(new ResponseMessageBuilder()
.code(403)
.message("资源不可用")
.build());
}})
问题解决。不知道是不是代码有问题,如果有问题希望可以起到一些帮助作用,如果是我理解有误,希望可以得到指正。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.