sprig整合hibernate定义扫描的类

我们使用spring整合hibernate的时候,通用需要指定默认扫描的类,在指定的地方可以用*匹配多个字符,非常实用。当然也可以逐个指定。

<!-- 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">${hibernate.dialect}</prop>
				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
				<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
				<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache/ehcache-hibernate-local.xml</prop>
			</props>
		</property>
		<property name="packagesToScan">
			<list>
				<value>com.companyname.*.entity</value>
			</list>
		</property>
	</bean>


sprig整合hibernate定义扫描的类
  

 

 

 

 

 

你可能感兴趣的:(Hibernate)