Spring Operation

Spring框架核心点:

  1. 依赖注入控制反转(IOC/DI),。
  2. 面向切面AOP。
  3. 事务处理。

怎么获取Spring容器的bean对象:

// 1.拿到Spring容器
ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");
// 2.获取Spring容器的bean对象
HelloWolrd hw1 = (HelloWolrd) ac.getBean("helloWolrd");

怎么创建一个bean:

 

      

创建一个抽象bean:



    
    

创建一个继承bean:



    

创建一个依赖bean:



    
    
    

设置bean的作用域




    

引入properties文件:





    
        
        
        
        
    

SPEL表达式语言使用


    
        
        
        
        
    

使用注解必须在spring配置文件中引入一下标签




@Component
@Service("userService")
@Repository

@Autowired

Bean的声明周期


    
        
    

Bean的前后置处理器


    

静态工厂方法配置Bean



    

实例工厂方法配置Bean


 

  

你可能感兴趣的:(Spring Operation)