Added default view resolver to fix issue with swagger ui

This commit is contained in:
2020-07-07 22:15:02 +02:00
parent 8c4e8b063d
commit 6a68afc62b

View File

@ -10,6 +10,7 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -18,24 +19,29 @@ import java.util.List;
@Configuration @Configuration
public class WebConfig implements WebMvcConfigurer { public class WebConfig implements WebMvcConfigurer {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new TraceIdInterceptor()); registry.addInterceptor(new TraceIdInterceptor());
registry.addInterceptor(new RequestTypeInterceptor()); registry.addInterceptor(new RequestTypeInterceptor());
} }
@Bean @Bean
public RestTemplate restTemplate() { public InternalResourceViewResolver defaultViewResolver() {
RestTemplate restTemplate = new RestTemplate(); return new InternalResourceViewResolver();
}
List<ClientHttpRequestInterceptor> interceptors
= restTemplate.getInterceptors(); @Bean
if (CollectionUtils.isEmpty(interceptors)) { public RestTemplate restTemplate() {
interceptors = new ArrayList<>(); RestTemplate restTemplate = new RestTemplate();
List<ClientHttpRequestInterceptor> interceptors
= restTemplate.getInterceptors();
if (CollectionUtils.isEmpty(interceptors)) {
interceptors = new ArrayList<>();
}
interceptors.add(new TraceIdInterceptor());
interceptors.add(new RequestTypeInterceptor());
restTemplate.setInterceptors(interceptors);
return restTemplate;
} }
interceptors.add(new TraceIdInterceptor());
interceptors.add(new RequestTypeInterceptor());
restTemplate.setInterceptors(interceptors);
return restTemplate;
}
} }