0

I have developed a REST server with our app specific APIs. we also have deployed a different rest Job server into another location. Currently the way I am doing is .

@RestController
public class SparkJobController  {

    @Autowired
    private IJobSchedulerService jobService;
...

And the Service Implementation is

@Service(value="jobService")
public class JobSchedulerServiceImpl implements IJobSchedulerService {

    @Override
    public Map triggerJob(String context) {

        Map<String, ?> s = new HashMap<String,Object>();
        RestTemplate restTemplate = new RestTemplate();
//      restTemplate call to other REST API. and returns Map.
    ...     
}

My question is , Is my approach correct ? Or Does Spring framework enables us to use some predefined APIs which can help to use RESTTemplate as a Service

[EDIT] : the deployed REST service is third party application.

4

1 回答 1

0

我做了一些研究,但还没有看到将 RestTemplate 实现为服务的方法。

我已经看到在 bean 配置中定义的 RestTemplate 并自动连接 - https://www.informit.com/guides/content.aspx?g=java&seqNum=546

总而言之,我见过的大多数示例都使用 Resttemplate,类似于您在代码中实现的方式。

于 2015-03-20T07:46:37.370 回答