简体   繁体   中英

Spring Autowire Resttemplate As Factory Bean?

When I debug my code I see that creating Resttemplate takes time. What happens about performance if I autowire it via Spring? Does Spring offers a factory pattern for injected beans?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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