cainawuha / Pro-Spring-5th-notes

0 stars 0 forks source link

IOC #3

Open cainawuha opened 3 years ago

cainawuha commented 3 years ago

a configuration class can import bean definitions from an XML file (or more) using @ImportResource

@ImportResource(locations = {"classpath:spring/app-context-xml.xml"}) @Configuration public class HelloWorldConfiguration { }

cainawuha commented 3 years ago

@ImportResource(locations = {"classpath:spring/app-context-xml.xml"}) @Configuration public class HelloWorldConfiguration { }

where we were able to use identity comparison (==) rather than the equals() comparison to check whether the beans were the same

we add the scope attribute and set the value to prototype. Spring defaults the scope to the value singleton. The prototype scope instructs Spring to instantiate a new instance of the bean every time a bean instance is requested by the application