Pet*_*zov 8 spring swagger swagger-2.0 springfox
我迁移到最新springfox-swagger2版本,2.10.0但看起来@EnableSwagger2已被弃用。
为了在 Spring Boot 项目中启用 Swagger,我应该使用什么注释?@EnableSwagger2WebMvc?
vaq*_*han 14
@EnableSwagger2 在 swagger 2.10+ 中被弃用
@EnableSwagger2WebMvc 在 3.0.0+ 中被弃用
有趣但真实:)
现在您可以在 Spring 5 MVC 中使用以下依赖项
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
和
见:https : //github.com/springfox/springfox
@Configuration
@EnableSwagger2WebMvc
@Import({SpringDataRestConfiguration.class, BeanValidatorPluginsConfiguration.class})
public class ApplicationSwaggerConfig {
@Bean
public Docket schoolApi() {
return new Docket(DocumentationType.SWAGGER_2).
select().
apis(RequestHandlerSelectors.basePackage("com.example.SampleProject")).
paths(PathSelectors.any()).
build();
}
Run Code Online (Sandbox Code Playgroud)
对于与 Spring 安全检查有关的其他情况,您可以使您的安全配置类扩展 WebsecurityConfigurerAdapter,然后您可以实现以下方法 -
@Override public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers( "/v2/api-docs", "/swagger-resources/**", "/configuration/ui","/configuration/security", "/swagger-ui.html");
}
Run Code Online (Sandbox Code Playgroud)
我想这应该有帮助
| 归档时间: |
|
| 查看次数: |
14929 次 |
| 最近记录: |