After starting the springboot project, the following error will be reported if the swagger page cannot be opened:
after checking the data, it is found that webmvcconfig custom inherits webmvcconfigureradapter in the code, which causes the configuration related contents in the configuration file to be invalid, and the static resources need to be specified again
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Value("${file.front-end.path}")
private String fePath;
@Value("${file.up-down-load.static-path}")
private String udlPath;
/**
* Static resource handling
**/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations(fePath,udlPath);
}
/**
* Front and back-end separation to solve cross-domain problems
**/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("*")
.allowedOrigins("*")
.allowCredentials(true);
}
//Allow multiple request addresses with extra slashes e.g. /msg/list //msg/list
@Bean
public HttpFirewall httpFirewall() {
return new DefaultHttpFirewall();
}
}
It is amended as follows:
/**
* Static resource handling
**/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations(fePath,udlPath);
// Add access to swagger pages
registry.addResourceHandler("swagger-ui.html").addResourceLocations(
"classpath:/META-INF/resources/");
}
Login again, access success
Read More:
- There was an unexpected error (type=Method Not Allowed, status=405). Request
- Springboot Error: There was an unexpected error (type = internal server error, status = 500)
- How to Solve Internal Server Error: /swagger/v1/swagger.json
- [Solved] swagger Error: Fetch errorInternal Server Error /swagger/v1/swagger.jso
- [Solved] A needed class was not found. This could be due to an error in your runpath. Missing class: scala/co
- Vue Browser Error: Failed to load resource: the server responded with a status of 404 (Not Found)
- [Solved] Swagger Error: Whitelabel Error Page status=405
- [Solved] FileUploadException: the request was rejected because no multipart boundary was found
- Zeal Open html,css, javascript Error: Content rendering error
- Markdownpad2 Error: Html Rendering Error (An error occurred with the Html rendering component.)
- [Solved] Instantiation of ‘sdram_model_plus‘ failed. The design unit was not found.
- Libtorch Error: Expected object of type Variable but found type CUDALongType for argument #2 ‘index’
- [Solved] Vue3 Error: export ‘createRouter‘ was not found in ‘vue-router‘
- Cordova – CordovaError: Promise rejected with non-error: ‘ios-deploy was not found
- The imported project “c:\Microsoft.Cpp.Default.props” was not found
- JSP error: The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- C# Error: Import “google/protobuf/timestamp.proto“ was not found or had errors. [How to Solve]
- [Solved] Vscode Error: “export ‘default‘ (imported as ‘VueRouter‘) was not found in ‘vue-router‘
- laravel Error mews/captcha is locked to version 3.2.4 and an update of this package was not requested.
- Echars 5.0 Import Error: “export ‘default’ (imported as ‘echarts’) was not found in ‘echarts’