spring rest client
@RestController
@RequestMapping("/another")
public class AnotherController {
@RequestMapping("/add")
public int add(@RequestParam("offset") int offset) {
// do something
return offset ;
}
}
@RequestMapping("/another")
@SpringRestClientEnabled(baseUrl = "http://localhost:8080")
public interface AnotherApi {
@RequestMapping("/add")
int add(@RequestParam("offset") int offset);
}
And then import spring-rest-client config like this:
@Configuration
@ComponentScan
@SpringRestClientEnabledScan
public class SpringRestClientConfig {
}
And then you can call the api like this:
@Autowired AnotherApi anotherApi;
int a = 123;
int account = anotherApi.add(a);