chaojiwanwan 2013-12-03
<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.DerbyDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> <property name="mappingDirectoryLocations"> <value>classpath:cn/jbit/entity</value> </property> </bean>例如:hibernate.show_sql,hibernate.hbm2ddl.auto 值可以为"create"时当服务器启动时,会自动检查数据库是否存在映射关系的表格,如果没有将会进行创建,当创建完成后请改为"update"。
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${driverClass}"> </property> <property name="jdbcUrl" value="${jdbcUrl}"> </property> <property name="user" value="classiccars"></property> <property name="password" value="myeclipse"></property> <property name="maxPoolSize" value="50" /> <property name="minPoolSize" value="1" /> <property name="initialPoolSize" value="1" /> <property name="maxIdleTime" value="60" /> <property name="checkoutTimeout" value="2000" /> </bean>
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class>com.jbit.util.OpenSessionInViewFilter</filter-class> </filter>