In Java for generic types, such as simple class definitions
Class Processor<t> {}
If you want to specify a specific type when initializing directly, we can write the
processor<string> Processor = new processor<> (); //java 7 and later
spring initialization of a basic generic
If we're going to initialize this class with the Spring container, like adding a @Named annotation to the class above
@Named
Class Processor<t> {
}
This time we passedbeanFactory.getBean(Processor.class)
What kind of an instance do you get? How does Spring know what specific type to specify? Very simply, any uncertain situation is an Object. So the container gets theProcessor
Instance is constructed from the following code.
Processor Processor = new Processor (); More precisely, processor<object> Processor = new processor<> ();
further , how does Spring respond to generic definitions with upper bound constraints? Like Read full text >>
How Spring Initializes a generic class instance