使用在SQL Server中执行查询的服务时,我的应用程序遇到错误FeignClient.
错误:
线程"pool-10-thread-14"中的异常feign.RetryableException:读取超时执行GET http://127.0.0.1:8876/processoData/search/buscaProcessoPorCliente?cliente=ELEKTRO+-+TRABALHISTA&estado=SP
我的消费者服务:
@FeignClient(url="http://127.0.0.1:8876")
public interface ProcessoConsumer {
@RequestMapping(method = RequestMethod.GET, value = "/processoData/search/buscaProcessoPorCliente?cliente={cliente}&estado={estado}")
public PagedResources<ProcessoDTO> buscaProcessoClienteEstado(@PathVariable("cliente") String cliente, @PathVariable("estado") String estado);
}
Run Code Online (Sandbox Code Playgroud)
我的YML:
server:
port: 8874
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
eureka:
client:
serviceUrl:
defaultZone: ${vcap.services.eureka-service.credentials.uri:http://xxx.xx.xxx.xx:8764}/eureka/
instance:
preferIpAddress: true
ribbon:
eureka:
enabled: true
spring:
application:
name: MyApplication
data:
mongodb:
host: xxx.xx.xxx.xx
port: 27017
uri: mongodb://xxx.xx.xxx.xx/recortesExtrator
repositories.enabled: true
solr:
host: http://xxx.xx.xxx.xx:8983/solr
repositories.enabled: true
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
谢谢.
我想在Spring Boot应用程序的配置类中RestTemplate使用@Bean注释定义为应用程序bean 。
我在应用程序流程中的不同位置调用了4个REST服务。目前,我RestTemplate每次创建每个请求。有没有一种方法可以将其定义为application bean using @Bean并使用using 注入@Autowired?
这个问题的主要原因是我可以定义RestTemplateusing,@Bean但是当我注入它时,我将@Autowired失去所有定义的拦截器(拦截器不会被调用。)
配置类别
@Bean(name = "appRestClient")
public RestTemplate getRestClient() {
RestTemplate restClient = new RestTemplate(
new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
interceptors.add(new RestServiceLoggingInterceptor());
restClient.setInterceptors(interceptors);
return restClient;
}
Run Code Online (Sandbox Code Playgroud)
服务等级
public class MyServiceClass {
@Autowired
private RestTemplate appRestClient;
public String callRestService() {
// create uri, method response objects
String restResp = appRestClient.getForObject(uri, method, response);
// do something with …Run Code Online (Sandbox Code Playgroud) 我在命令提示符下运行一个spring boot jar传递jvm参数
java -jar myjarname.jar -Denvironment=dev
Run Code Online (Sandbox Code Playgroud)
要么
java -jar myjarname.jar --environment=dev
Run Code Online (Sandbox Code Playgroud)
并尝试environment使用System.getProperty("environment")读取我的应用程序中的值.但它给了我无效的价值.请帮忙!!