Sobes.tech
Junior — Middle

What parameters and default values does the Spring container use when initializing a bean?

sobes.tech AI

Answer from AI

When initializing a bean in the Spring container, the following parameters and default values are used:

  • scope: defaults to singleton, meaning one instance of the bean is created for the entire context.
  • lazy-init: defaults to false, the bean is created at context startup.
  • autowire: defaults to no, autowiring is not performed unless explicitly specified.
  • init-method and destroy-method: not set by default, but methods for initialization and destruction can be specified.
  • primary: defaults to false, the bean is not preferred during autowiring.

Example of a bean configuration with default parameters:

@Component
public class MyBean {
    // the bean will be singleton and initialized at context startup
}
What parameters and default values does the Spring… - sobes.tech