Spring注入模型


spring
    IOC 是DI另一种说法  控制反转依赖注入
    spring bean == bean
    java object == object 对象
    bean是object object不一定是bean
    
    
    bean构建方式
    spring 1.0  xml
    
        <?xml version="1.0" encoding="UTF-8"?>
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.springframework.org/schema/beans
                https://www.springframework.org/schema/beans/spring-beans.xsd">

              
                
            


            
                
            


            

        

        
        // create and configure beans
        ApplicationContext context = new ClassPathXmlApplicationContext("services.xml", "daos.xml");

        // retrieve configured instance
        PetStoreService service = context.getBean("petStore", PetStoreService.class);

        // use configured instance
        List userList = service.getUsernameList();
        
        
    spring 2.5 annotation 注解
    3.0 java config
    
spring的自动注入 Autowiring modes(注入模式只针对于xml annotation 注解和java config不涉及) === xml -based

    no(Default)
    byname
    bytype
    constructor
    
    
    
    
    
    
    
spring 注入有哪几种方式