spring框架常用

一.IOC的原理


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

 

    




public static void main(String[] args) {
//初始化IOC容器,参数值是要加载的配置文件相对于src的相对路径
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//根据xml文件中的id来创建对象
FirstBean firstBean = (FirstBean) context.getBean("first");
//调用方法
firstBean.method1pspeak();
}

AOP的原理

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

 
 
 
 
 
    
 
 
 
        
        
 
 
 

你可能感兴趣的:(spring框架常用)