Guides

对guides这个词认识源于struts文档,参考、指南,这里是sfilyh 关于CODE的guides。

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  21 随笔 :: 1 文章 :: 5 评论 :: 0 Trackbacks
网上看到在spring里配置sessionFactory的另一种写法。

我一直用的配法

   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://192.168.1.111:3306/comment_new"/>
        
<property name="password" value="root" />
        
<property name="username" value="root" />
    
</bean>
    
    
<bean id="sessionFactory"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        
<property name="dataSource" ref="dataSource" />
        
<property name="mappingDirectoryLocations">
            
<list>
                
<value>classpath:com/cocosily/comment/po</value>
            
</list>
        
</property>

        
<property name="hibernateProperties">
            
<props>
                
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                
<prop key="hibernate.show_sql">true</prop>
                
<prop key="hibernate.format_sql">true</prop>
                
<prop key="hibernate.cache.use_query_cache">true</prop>
                
<prop key="hibernate.cache.use_second_level_cache">true</prop>
            
</props>
        
</property>
    
</bean>

见到别人的另一种配法,直接保留hibernate.cfg.xml配置文件。然后通过属性引入一下

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
    
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
</bean>


posted on 2011-11-19 11:16 Guides 阅读(2081) 评论(0)  编辑  收藏

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


网站导航: