Commit 870bc5f6 by Nepxion

修改restTemplateStrategyInterceptor注入方式

parent 27fb525a
...@@ -8,9 +8,6 @@ package com.nepxion.discovery.plugin.example.service; ...@@ -8,9 +8,6 @@ package com.nepxion.discovery.plugin.example.service;
* @author Haojun Ren * @author Haojun Ren
* @version 1.0 * @version 1.0
*/ */
import java.util.Collections;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
...@@ -50,7 +47,7 @@ public class DiscoveryApplicationA1 { ...@@ -50,7 +47,7 @@ public class DiscoveryApplicationA1 {
public RestTemplate restTemplate(@Autowired(required = false) RestTemplateStrategyInterceptor restTemplateStrategyInterceptor) { public RestTemplate restTemplate(@Autowired(required = false) RestTemplateStrategyInterceptor restTemplateStrategyInterceptor) {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
if (restTemplateStrategyInterceptor != null) { if (restTemplateStrategyInterceptor != null) {
restTemplate.setInterceptors(Collections.singletonList(restTemplateStrategyInterceptor)); restTemplate.getInterceptors().add(restTemplateStrategyInterceptor);
} }
return restTemplate; return restTemplate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment