学习 Spring -- beans.xml 文件的创建

学习 Spring -- beans.xml 文件的创建

beans.xml


<? xml version="1.0" encoding="UTF-8" ?>
< beans  xmlns ="http://www.springframework.org/schema/beans"  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
    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/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
>
    
< bean  id ="dataSource"  class ="org.apache.commons.dbcp.BasicDataSource" >
        
< property  name ="driverClassName"  value ="oracle.jdbc.driver.OracleDriver"   />
        
< property  name ="url"  value ="jdbc:oracle:thin:@localhost:1521:orcl"   />
        
< property  name ="username"  value ="yiqi"   />
        
< property  name ="password"  value ="yiqi"   />
    
</ bean >
    
< bean  id ="sessionFactory"  class ="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
        
< property  name ="dataSource"  ref ="dataSource"   />
        
< property  name ="hibernateProperties" >
            
< props >
                
< prop  key ="hibernate.dialect" > org.hibernate.dialect.Oracle10gDialect </ prop >
                
< prop  key ="hibernate.show_sql" > true </ prop >
                
< prop  key ="hibernate.jdbc.batch_size" > 1 </ prop >
                
< prop  key ="hibernate.hbm2ddl.auto" > create </ prop >
            
</ props >
        
</ property >
        
< property  name ="annotatedClasses" >
            
< list >
                
< value > com.exercise.hibernate.EnglishUser </ value >
            
</ list >
        
</ property >
    
</ bean >
    
< bean  id ="transactionManager"  class ="org.springframework.orm.hibernate3.HibernateTransactionManager" >
        
< property  name ="dataSource"  ref ="dataSource"   />
        
< property  name ="sessionFactory"  ref ="sessionFactory"   />
    
</ bean >
    
< tx:annotation-driven  />
    
< bean  id ="EnglishUserDAO"  class ="com.exercise.hibernate.EnglishUserDAOImpl" >
        
< property  name ="sessionFactory"  ref ="sessionFactory"   />
    
</ bean >
</ beans >




你可能感兴趣的:(学习 Spring -- beans.xml 文件的创建)