随笔-204  评论-149  文章-0  trackbacks-0
<?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:jee
="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context
="http://www.springframework.org/schema/context"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
    default-lazy-init
="true">

    
<description>Spring公共配置文件 </description>

    
<!-- 定义受环境影响易变的变量 -->
    
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
        
<property name="ignoreResourceNotFound" value="true" />
        
<!-- 属性文件读入 -->
        
<property name="locations">
            
<list>
                
<!-- 标准配置 -->
                
<value>classpath*:/application.properties</value>
                
<!-- 本地开发环境配置 -->
                
<value>classpath*:/application.local.properties</value>
                
<!-- 服务器生产环境配置 -->
                
<!-- <value>file:/var/myapp/application.server.properties</value> -->
            
</list>
        
</property>
    
</bean>

    
<!-- 使用Spring annotation 自动注册bean,并保证@Autowired(required=false/true)的属性被注入 -->
    
<!-- 将打开组件扫描配置项base-package表示自动扫描org.springside.example.miniwe包以及它的子包 -->
    
<!-- 
    spring2.5引入了组件自动扫描的机制,可以采用在classpath自动扫描方式把classpath中所有的组件都纳入到spring 容器来进行管理。
    但是这些类需要使用使用 @Service,@Controller, @Repository 这几个注解。它的作用与在xml文件中使用bean节点配置组件式一样的。
   ·@Service用于标注业务层组件
   ·@Controller用于标注控制层组件,比如struts中的action
   ·@Repository用于标注数据访问组件,如DAO组件
   ·@Component泛指组件,当组件不好归类的时候,我们可以使用它进行标注
     
-->
    
<!-- context:component-scan base-package="org.springside.examples.miniweb" -->
    
<context:component-scan base-package="edu.b.recommender" />

    
<!-- 数据源配置,使用应用内的DBCP数据库连接池 -->
    
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        
<!-- Connection Info -->
        
<property name="driverClassName" value="${jdbc.driverClassName}" />
        
<property name="url" value="${jdbc.url}" />
        
<property name="username" value="${jdbc.username}" />
        
<property name="password" value="${jdbc.password}" />

        
<!-- Connection Pooling DBCP -->
        
<property name="initialSize" value="5" />
        
<property name="maxActive" value="100" />
        
<property name="maxIdle" value="30" />
        
<property name="maxWait" value="1000" />
        
<property name="poolPreparedStatements" value="true" />
        
<property name="defaultAutoCommit" value="false" />
    
</bean>

    
<!-- 数据源配置,使用应用服务器的数据库连接池 -->
    
<!--<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/ExampleDB" />-->

    
<!-- Hibernate配置 使用注解来取代了.hbm.xml文件 -->
    
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        
<property name="dataSource" ref="dataSource" />
        
<property name="namingStrategy">
            
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
        
</property>
        
<property name="hibernateProperties">
            
<props>
                
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
                
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                
<prop key="hibernate.use_outer_join">${hibernate.use_outer_join}</prop>
                
<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
                
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
                
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
                
<!--是否使用查询缓存  <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> -->
                
<prop key="hibernate.cache.provider_configuration_file_resource_path">${hibernate.ehcache_config_file}</prop>
            
</props>
        
</property>
        
<!-- 使用Hibernate annotation自动扫描此包中的实体类po,这些po使用JPA注解来映射数据库文件 -->
        
<property name="packagesToScan" value="edu.b.recommender.*" />
    
</bean>

    
<!-- 事务管理器配置,单数据源事务 -->
    
<!-- Transaction事务处理使用Spring来托管事务的处理 -->
    
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        
<property name="sessionFactory" ref="sessionFactory" />
    
</bean>

    
<!-- 事务管理器配置,多数据源JTA事务-->
    
<!--
        <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager or
        WebLogicJtaTransactionManager" />
    
-->

    
<!-- 使用annotation定义事务 -->
    
<!-- 支持 @Transactional 标记 -->
    
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
posted on 2009-05-03 19:42 Frank_Fang 阅读(466) 评论(0)  编辑  收藏 所属分类: SSH+JQuery+DWR

只有注册用户登录后才能发表评论。


网站导航: