Commit 28b4eba8 by Nepxion

修正小Bug

parent f6106249
...@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.example.service; ...@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.example.service;
import java.util.Collections; import java.util.Collections;
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;
import org.springframework.cloud.alibaba.sentinel.annotation.SentinelProtect; import org.springframework.cloud.alibaba.sentinel.annotation.SentinelProtect;
...@@ -46,7 +47,7 @@ public class DiscoveryApplicationA1 { ...@@ -46,7 +47,7 @@ public class DiscoveryApplicationA1 {
@Bean @Bean
@LoadBalanced @LoadBalanced
@SentinelProtect(blockHandler = "handleException", blockHandlerClass = MySentinelExceptionHandler.class) @SentinelProtect(blockHandler = "handleException", blockHandlerClass = MySentinelExceptionHandler.class)
public RestTemplate restTemplate(RestTemplateStrategyInterceptor restTemplateStrategyInterceptor) { public RestTemplate restTemplate(@Autowired(required = false) RestTemplateStrategyInterceptor restTemplateStrategyInterceptor) {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
restTemplate.setInterceptors(Collections.singletonList(restTemplateStrategyInterceptor)); restTemplate.setInterceptors(Collections.singletonList(restTemplateStrategyInterceptor));
......
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