springMVC與hibernate 配置代碼片斷spring
<beans> <bean id = "dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@localhost:1521:ORCL" /> <property name="userName" value="spring" /> <property name="password" value="spring" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10Dialect</prop> 只要bibernate映射文件改變就更新數據庫裏面的表,不用手動建立,自動更新,若是將update改爲create,則每次更新的時候會將以前的表及數據所有刪除 <prop key="hibernate.hbm2ddl.auto">update</prop> 打印sql語句 <prop key="hibernate.show_sql">true</prop> 格式化sql語句 <prop key="hibernate..format_sql">true</prop> </props> </property> </bean>
</beans>sql