Spring Hibernate SessionFactory packagesToScan Bug

Java代码
<!-- Hibernate配置 --> 
 
<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"> 
                org.hibernate.dialect.MySQL5Dialect 
            </prop> 
            <prop key="hibernate.show_sql"> 
                ${hibernate.show_sql} 
            </prop> 
            <prop key="hibernate.format_sql"> 
                ${hibernate.format_sql} 
            </prop> 
            <prop key="hibernate.hbm2ddl.auto">update</prop> 
            <prop key="hibernate.cache.provider_class"> 
                org.hibernate.cache.EhCacheProvider 
            </prop> 
            <prop 
                key="hibernate.cache.provider_configuration_file_resource_path"> 
                    ${hibernate.ehcache_config_file} 
            </prop> 
        </props> 
    </property> 
 
    <!-- 使用packagesToScan属性已批量定义了sessionFactory加载的实体对象 --> 
    <property name="packagesToScan" value="com.store.entity.*" /> 
 
    <!-- 
    <property name="annotatedClasses"> 
            <list> 
                <value>com.store.entity.Item</value>           
            </list> 
     </property>  
    --> 
</bean> 


上面的packagesToScan扫描的范围为 com.store.entity下的包,不能把Entity直接放在com.store.entity下面,Spring不扫描此包。

你可能感兴趣的:(spring,sql,Hibernate,cache)