|
|
@ -9,13 +9,14 @@ import com.gitee.sop.servercommon.message.ServiceErrorFactory; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.http.converter.HttpMessageConverter; |
|
|
|
import org.springframework.http.converter.HttpMessageConverter; |
|
|
|
import org.springframework.http.converter.StringHttpMessageConverter; |
|
|
|
import org.springframework.http.converter.StringHttpMessageConverter; |
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|
|
|
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.WebMvcConfigurer; |
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; |
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
import javax.annotation.PostConstruct; |
|
|
@ -26,7 +27,7 @@ import java.util.List; |
|
|
|
* @author tanghc |
|
|
|
* @author tanghc |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
public class BaseServiceConfiguration extends WebMvcConfigurationSupport { |
|
|
|
public class BaseServiceConfiguration implements WebMvcConfigurer, WebMvcRegistrations { |
|
|
|
|
|
|
|
|
|
|
|
public BaseServiceConfiguration() { |
|
|
|
public BaseServiceConfiguration() { |
|
|
|
ServiceConfig.getInstance().getI18nModules().add("i18n/isp/bizerror"); |
|
|
|
ServiceConfig.getInstance().getI18nModules().add("i18n/isp/bizerror"); |
|
|
@ -38,8 +39,7 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport { |
|
|
|
private Environment environment; |
|
|
|
private Environment environment; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void addResourceHandlers(ResourceHandlerRegistry registry) { |
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) { |
|
|
|
super.addResourceHandlers(registry); |
|
|
|
|
|
|
|
// 支持swagger-bootstrap-ui首页
|
|
|
|
// 支持swagger-bootstrap-ui首页
|
|
|
|
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); |
|
|
|
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); |
|
|
|
// 支持默认swagger
|
|
|
|
// 支持默认swagger
|
|
|
@ -48,14 +48,13 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void addInterceptors(InterceptorRegistry registry) { |
|
|
|
public void addInterceptors(InterceptorRegistry registry) { |
|
|
|
// 添加拦截器
|
|
|
|
// 添加拦截器
|
|
|
|
registry.addInterceptor(new ServiceContextInterceptor()); |
|
|
|
registry.addInterceptor(new ServiceContextInterceptor()); |
|
|
|
super.addInterceptors(registry); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void extendMessageConverters(List<HttpMessageConverter<?>> converters) { |
|
|
|
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) { |
|
|
|
// 解决controller返回字符串中文乱码问题
|
|
|
|
// 解决controller返回字符串中文乱码问题
|
|
|
|
for (HttpMessageConverter<?> converter : converters) { |
|
|
|
for (HttpMessageConverter<?> converter : converters) { |
|
|
|
if (converter instanceof StringHttpMessageConverter) { |
|
|
|
if (converter instanceof StringHttpMessageConverter) { |
|
|
@ -69,7 +68,7 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport { |
|
|
|
* @return 返回RequestMappingHandlerMapping |
|
|
|
* @return 返回RequestMappingHandlerMapping |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { |
|
|
|
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { |
|
|
|
return apiMappingHandlerMapping; |
|
|
|
return apiMappingHandlerMapping; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|