提交 fd648f2e authored 作者: inroi's avatar inroi

微调

上级 8aa58d67
package com.framework.core.config; package com.framework.core.config;
//import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import com.framework.core.constant.CommonConstant; import com.framework.core.constant.CommonConstant;
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
...@@ -27,7 +28,7 @@ import java.util.List; ...@@ -27,7 +28,7 @@ import java.util.List;
@Configuration @Configuration
@EnableSwagger2 @EnableSwagger2
//@ConditionalOnProperty(name = "swagger.enabled", havingValue = "true") //@ConditionalOnProperty(name = "swagger.enabled", havingValue = "true")
public class SwaggerConfig extends WebMvcConfigurationSupport { public class SwaggerConfig implements WebMvcConfigurer {
//api接口包扫描路径 //api接口包扫描路径
public static final String SWAGGER_SCAN_BASE_PACKAGE = "com"; public static final String SWAGGER_SCAN_BASE_PACKAGE = "com";
@Value("${spring.application.name}") @Value("${spring.application.name}")
...@@ -113,7 +114,7 @@ public class SwaggerConfig extends WebMvcConfigurationSupport { ...@@ -113,7 +114,7 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
.version("1.0") .version("1.0")
// .termsOfServiceUrl("NO terms of service") // .termsOfServiceUrl("NO terms of service")
// 描述 // 描述
.description(applicationName+"后台API接口") .description(applicationName + "后台API接口")
// 作者 // 作者
// .contact("") // .contact("")
.license("The Apache License, Version 2.0") .license("The Apache License, Version 2.0")
...@@ -123,21 +124,14 @@ public class SwaggerConfig extends WebMvcConfigurationSupport { ...@@ -123,21 +124,14 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
/** /**
* 防止@EnableMvc把默认的静态资源路径覆盖了,手动设置的方式 * 防止@EnableMvc把默认的静态资源路径覆盖了,手动设置的方式
*
* @param registry
*/ */
@Override @Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
// 解决静态资源无法访问 registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/");
// 解决swagger无法访问
registry.addResourceHandler("/swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
// 解决swagger的js文件无法访问
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
} }
} }
...@@ -21,8 +21,9 @@ import java.util.List; ...@@ -21,8 +21,9 @@ import java.util.List;
/** /**
* @author Inori * @author Inori
*/ */
@EnableWebMvc
@Configuration @Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport { public class WebMvcConfig implements WebMvcConfigurer {
@Override @Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) { public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
......
...@@ -80,7 +80,7 @@ security: ...@@ -80,7 +80,7 @@ security:
client-id: user-client client-id: user-client
client-secret: user-secret-8888 client-secret: user-secret-8888
# user-authorization-uri: http://127.0.0.7:${server.port}/oauth/authorize # user-authorization-uri: http://127.0.0.7:${server.port}/oauth/authorize
access-token-uri: http://localhost:${server.port}/oauth/token access-token-uri: http://localhost:${server.port}/nzwz/oauth/token
resource: resource:
jwt: jwt:
#key-uri: http://starbos-auth-system:6001/oauth/token_key #key-uri: http://starbos-auth-system:6001/oauth/token_key
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论