Swagger 未检测到控制器
Swagger
未检测到任何控制器并显示不同类型的错误请求
SwaggerConfig :
@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("tn.esprit.spring.controllers"))//Package+Classes
.paths(PathSelectors.any()) //méthodes
.build().apiInfo(apiInfo());
}
private ApiInfo apiInfo () {
return new ApiInfoBuilder()
.title("Swagger Configuration for Woman Area 5Project")
.description("\"Spring Boot Swagger configuration\"")
.version("1.0").build();
}
}
主要:
@SpringBootApplication
@EnableSwagger2
public class ProjectApplication {
public static void main(String[] args) {
SpringApplication.run(ProjectApplication.class, args);
}
}
网络安全配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests().antMatchers("/api/auth/**").permitAll()
.antMatchers("/api/test/**").permitAll()
.antMatchers("/createcandidate").permitAll()
.antMatchers("/downloadFile/{fileName:.+}").permitAll()
.antMatchers("/avatar/{id}").permitAll()
.antMatchers("/employees/{id}").permitAll()
.antMatchers("/dureeConge/{id}").permitAll()
.anyRequest().authenticated();
http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/**");
}
Swagger
don't detect any controllers and show error request of different type
SwaggerConfig:
@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("tn.esprit.spring.controllers"))//Package+Classes
.paths(PathSelectors.any()) //méthodes
.build().apiInfo(apiInfo());
}
private ApiInfo apiInfo () {
return new ApiInfoBuilder()
.title("Swagger Configuration for Woman Area 5Project")
.description("\"Spring Boot Swagger configuration\"")
.version("1.0").build();
}
}
main:
@SpringBootApplication
@EnableSwagger2
public class ProjectApplication {
public static void main(String[] args) {
SpringApplication.run(ProjectApplication.class, args);
}
}
webSecurity config:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests().antMatchers("/api/auth/**").permitAll()
.antMatchers("/api/test/**").permitAll()
.antMatchers("/createcandidate").permitAll()
.antMatchers("/downloadFile/{fileName:.+}").permitAll()
.antMatchers("/avatar/{id}").permitAll()
.antMatchers("/employees/{id}").permitAll()
.antMatchers("/dureeConge/{id}").permitAll()
.anyRequest().authenticated();
http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/**");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论