parent
0489133d6d
commit
b3512f716a
5 changed files with 66 additions and 1 deletions
@ -0,0 +1,35 @@ |
||||
package com.daqing.financial.config; |
||||
|
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import springfox.documentation.builders.ApiInfoBuilder; |
||||
import springfox.documentation.builders.PathSelectors; |
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
||||
import springfox.documentation.service.ApiInfo; |
||||
import springfox.documentation.spi.DocumentationType; |
||||
import springfox.documentation.spring.web.plugins.Docket; |
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
||||
|
||||
@Configuration |
||||
@EnableSwagger2 |
||||
//@Profile({"dev","test"})
|
||||
//@ConditionalOnProperty(name = "swagger.enable", havingValue = "true")
|
||||
public class SwaggerConfig { |
||||
|
||||
@Bean |
||||
public Docket productApi() { |
||||
return new Docket(DocumentationType.SWAGGER_2) |
||||
.apiInfo(apiInfo()) |
||||
.select()//添加ApiOperiation注解的被扫描
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
||||
.paths(PathSelectors.any()) |
||||
.build(); |
||||
} |
||||
|
||||
private ApiInfo apiInfo() { |
||||
return new ApiInfoBuilder().title("大庆智慧金融平台api文档").description("大庆智慧金融平台api文档") |
||||
.version("1.0").build(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,27 @@ |
||||
package com.daqing.financial.gateway.config; |
||||
|
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.cors.CorsConfiguration; |
||||
import org.springframework.web.cors.reactive.CorsWebFilter; |
||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; |
||||
|
||||
@Configuration |
||||
public class FinancialCorsConfiguration { |
||||
|
||||
@Bean |
||||
public CorsWebFilter corsWebFilter(){ |
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
||||
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration(); |
||||
|
||||
//1、配置跨域
|
||||
corsConfiguration.addAllowedHeader("*"); |
||||
corsConfiguration.addAllowedMethod("*"); |
||||
corsConfiguration.addAllowedOrigin("*"); |
||||
corsConfiguration.setAllowCredentials(true); |
||||
|
||||
source.registerCorsConfiguration("/**",corsConfiguration); |
||||
return new CorsWebFilter(source); |
||||
} |
||||
} |
Loading…
Reference in new issue