Is the singleton bean in the Spring framework thread-safe?
The singleton bean in the Spring framework is not thread-safe. (Recommended study:java interview questions)
What are Spring’s internal beans?
When a bean is only used as an attribute of another bean, it can be declared as an inner bean. In order to define the inner bean, in Spring's XML-based configuration metadata, you can The
What is bean autowiring?
There is no need to describe the dependencies between javaBeans in the Spring configuration file (such as configuring
Different ways of automatic assembly.
There are five automatic assembly methods that can be used to guide the Spring container to use automatic assembly for dependency injection.
no: The default method is not to perform automatic assembly, but to perform assembly by explicitly setting the ref attribute.
byName: Through automatic assembly of parameter names, the Spring container finds that the bean's autowire attribute is set to byname in the configuration file, and then the container tries to match and assemble a bean with the same name as the bean's attribute.
byType:: Through automatic assembly of parameter types, the Spring container finds that the autowire attribute of the bean is set to byType in the configuration file, and then the container attempts to match and assemble beans of the same type as the bean's attributes. If more than one bean meets the criteria, an error is thrown.
constructor: This method is similar to byType, but it must be provided to the constructor parameter. If there is no determined constructor parameter type with parameters, an exception will be thrown.
autodetect: First try to use constructor for automatic assembly. If it doesn't work, use byType method.
How to inject a java collection in Spring?
Spring provides the following configuration elements for collections:
type is used to inject a list of values, allowing the same value.
The
The above is the detailed content of Spring bean basic interview questions and answers. For more information, please follow other related articles on the PHP Chinese website!