springfox: Swagger url throwing 404
Hi,
I have a spring mvc web services maven project and I need to configure swagger for it. I am getting 404 not found error on accessing swagger through http://localhost:8080/test/v2/api-docs.
I have created a swagger configuration file as below
@Configuration
@EnableWebMvc
@EnableSwagger2
@ComponentScan(basePackages = { "com.xxx.test" })
public class MvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
System.out.println("Reached configuration");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
Added the below dependencies
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-web</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-common</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.2.2</version>
</dependency>
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (6 by maintainers)
Commits related to this issue
- Added warning when specification group doesnt exist in the cache related to #1160 — committed to springfox/springfox by dilipkrish 6 years ago
You are correct 404 is the right status code. However, what I was saying is something else. That is, in order to help the developer know why he was getting a 404, either add some content into the response with an explanation of why the 404 error occurred. Or log a message to the logger why that happened. Because that would help us identify the issue sooner and not waste time having to dig into the code (like myself) to find out where the issue was coming from.