简体   繁体   English

Spring Autowire Resttemplate作为工厂Bean?

[英]Spring Autowire Resttemplate As Factory Bean?

When I debug my code I see that creating Resttemplate takes time. 当我调试代码时,我看到创建Resttemplate需要时间。 What happens about performance if I autowire it via Spring? 如果我通过Spring自动接线,性能会如何? Does Spring offers a factory pattern for injected beans? Spring是否为注入的豆提供工厂模式?

是的,Spring确实为注入的Bean提供了一种工厂模式,但是在您的情况下,由于Spring的默认Bean行为是单例,因此您只需要配置一次RestTemplate,然后注入到需要的任何类中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM