相关疑难解决方法(0)

春豆的生命周期是什么?

我对Spring的生命周期感到困惑.

XmlBeanFactory beanFactory 
= new XmlBeanFactory(new ClassPathResource("SpringHelloWorld.xml"));
Run Code Online (Sandbox Code Playgroud)

上面的代码片段是否创建了对象?

如果上述答案是真的.

a)然后,对于范围为"singleton"的bean,获取在上面的代码片段中创建的对象.我是对还是错?

b)对于范围是"原型"的情况,创建的对象是否未使用.因为,容器总是返回新对象.

XmlBeanFactory beanFactory 
= new XmlBeanFactory(new ClassPathResource("SpringHelloWorld.xml"));
Run Code Online (Sandbox Code Playgroud)

上面的代码片段是否创建了对象?

如果答案是假的,

spring框架如何验证bean定义是否正确.

From the answer of Henry

Usually, singleton beans are created when the context starts. This can be changed with the lazy-init or default-lazy-init attributes.

Prototype beans are only created when needed.

Only syntactically, there might still be errors when the bean is instantiated, for example if a required property is not provided.

java lifecycle spring

11
推荐指数
1
解决办法
6133
查看次数

标签 统计

java ×1

lifecycle ×1

spring ×1