@Bean @Primary public TestRestTemplate zg2TestRestTemplate(ObjectProvider<RestTemplateBuilder> builderProvider, Environment environment) { SimpleModule sm = new SimpleModule(); Zg2proRestTemplate rt = new Zg2proRestTemplate(sm); TestRestTemplate trt = new TestRestTemplate(rt); trt.setUriTemplateHandler(new LocalHostUriTemplateHandler(environment)); return trt; }
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { RestTemplateBuilder builder = getRestTemplateBuilder(applicationContext); TestRestTemplate template = new TestRestTemplate(builder.build()); template.setUriTemplateHandler( new LocalHostUriTemplateHandler(applicationContext.getEnvironment())); this.object = template; }