spring+mybatis

阅读更多

//读取spring配置文件
//根据src\test\java\的路径得到配置文件路径
BeanFactory beanFactory = new ClassPathXmlApplicationContext(配置文件);
//通过spring配置文件生成的beanFactory获得SqlSessionFactory
SqlSessionFactory factory = (SqlSessionFactory) beanFactory
                .getBean("sqlSessionFactory");

 

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

 
   destroy-method="close">
  
  
  
  
  

  
  
  
  
  
  
  
 

 
   class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  
 

 
  
  
 

你可能感兴趣的:(spring+mybatis)