spring IOC DI has spring factory class

IOC to reverse control, the control is initialized bean class, create the right framework to spring, rather than new a new object.

DI is a dependency injection, inject bean class attribute, SET injection, constructor injection.

<bean id="userService" class="com.imooc.ioc.demo1.UserServiceImpl">
        <property name="name" value="李四"/>
    </bean>

 

:( traditional spring factory class factory class BeanFactory)

ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");

When ApplicationContext is used at startup to load the configuration file so that the bean class instantiated.

Guess you like

Origin blog.csdn.net/song_chengbo/article/details/97396484