Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring Autowire Resttemplate作为工厂Bean?_Java_Spring_Resttemplate - Fatal编程技术网

Java Spring Autowire Resttemplate作为工厂Bean?

Java Spring Autowire Resttemplate作为工厂Bean?,java,spring,resttemplate,Java,Spring,Resttemplate,调试代码时,我发现创建Resttemplate需要时间。如果我通过Spring自动连线,性能会怎么样?Spring是否为注入的bean提供工厂模式?是的,Spring确实为注入的bean提供工厂模式,但在您的情况下,由于Spring默认bean行为是单例的,所以您只需要配置RestTemplate一次,然后将它注入到中所需的任何类中,您所说的Spring为注入的bean提供工厂模式是什么意思?Spring是一个IoC容器。它管理你的豆子。创建一个restemplatebean并将其注入到任何地方

调试代码时,我发现创建Resttemplate需要时间。如果我通过Spring自动连线,性能会怎么样?Spring是否为注入的bean提供工厂模式?

是的,Spring确实为注入的bean提供工厂模式,但在您的情况下,由于Spring默认bean行为是单例的,所以您只需要配置RestTemplate一次,然后将它注入到

中所需的任何类中,您所说的Spring为注入的bean提供工厂模式是什么意思?Spring是一个IoC容器。它管理你的豆子。创建一个
restemplate
bean并将其注入到任何地方。