简化Spring - SessionFactory - mappingResources的配置

原来的代码:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
	<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver">
	</property>
	<property name="url" value="jdbc:oracle:thin:@localhost:1521:oracleName">
	</property>
	<property name="username" value="******"></property>
	<property name="password" value="******"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
	<property name="dataSource">
		<ref bean="dataSource" />
	</property>
	<property name="hibernateProperties">
		<props>
			<prop key="hibernate.dialect">
			      org.hibernate.dialect.Oracle9Dialect
			</prop>
		</props>
	</property>
	<property name="mappingResources">
	<list>
		<value>packagelocation</value>
		<value>packagelocation</value>
	</list>
	</property>
</bean>

简化后的代码:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
	<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver">
	</property>
	<property name="url" value="jdbc:oracle:thin:@localhost:1521:changluo">
	</property>
	<property name="username" value="******"></property>
	<property name="password" value="******"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
	<property name="dataSource">
		<ref bean="dataSource" />
	</property>
	<property name="hibernateProperties">
		<props>
			<prop key="hibernate.dialect">
			      org.hibernate.dialect.Oracle9Dialect
			</prop>
		</props>
	</property>

	<property name="mappingDirectoryLocations">
		<value>classpath:/配置文件位置</value>
	</property>
</bean>

你可能感兴趣的:(java,spring,Hibernate,xml)