In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article "SpringBoot configuration SwaggerUI access error how to solve" most people do not understand, so the editor summarizes the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "SpringBoot configuration SwaggerUI access error how to solve" article.
SpringBoot configures SwaggerUI to access the pit of 404.
I encountered a small pit while learning SpringBoot to build Restful API, and I couldn't access it when configuring Swagger UI.
First, add the Swagger dependency to your pom file, as shown below:
Io.springfox springfox-swagger-ui 2.2.2 io.springfox springfox-swagger2 2.2.2
Then create a new SwaggerConfig class:
Configuration@EnableSwagger2public class SwaggerConfig {@ Bean public Docket createRestApi () {return new Docket (DocumentationType.SWAGGER_2) .apiInfo (apiInfo ()) .select () .apis (RequestHandlerSelectors.basePackage ("com.nightowl")) .build () } private ApiInfo apiInfo () {return new ApiInfoBuilder () .title ("NightOwl RESTful APIs") .description ("follow me http://hwangfantasy.github.io/") .termsOfServiceUrl (" http://hwangfantasy.github.io/") .contact ") .version (" 1.0") .build ();}}
Finally, you can add a series of API annotations to your Controller, but you can use them normally without adding API annotations.
Finally, you can see the swagger page by visiting localhost:8080/swagger-ui.html.
But here's the point. The first time I configured it in this way, I prompted the following error:
Whitelabel Error PageThis application has no explicit mapping for / error, so you are seeing this as a fallback.Thu Nov 24 19:57:13 CST 2016There was an unexpected error (type=Not Found, status=404). No message available
But I didn't have any problems with reconfiguring a new project, so I thought of which configurations in my project must conflict with swagger.
Finally, it is found that in application.properties
Spring.resources.static-locations=classpath:/static/
This line is commented out and you can access it.
The above is about "SpringBoot configuration SwaggerUI access 404 error how to solve" this article, I believe we all have a certain understanding, I hope the editor to share the content to help you, if you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.