1 <jdbc:embedded-database id="dataSourceDERBY" type="DERBY"></jdbc:embedded-database> 2 <jdbc:embedded-database id="dataSourceHSQL" type="HSQL"></jdbc:embedded-database> 3 <jdbc:embedded-database id="dataSourceH2" type="H2"></jdbc:embedded-database> 4 <bean 5 id="sessionFactory" 6 class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 7 <property name="dataSource"> 8 <ref bean="dataSourceH2"/> 9 </property> 10 <property name="hibernateProperties"> 11 <props> 12 <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop> 13 <prop key="hibernate.show_sql">true</prop> 14 <prop key="hibernate.format_sql">true</prop> 15 <prop key="hibernate.hbm2ddl.auto">update</prop> 16 </props> 17 </property> 18 <!-- 19 <property name="annotatedClasses"> 20 <list> 21 <value>zwh.spring.security.po.User</value> 22 <value>zwh.spring.security.po.Role</value> 23 </list> 24 </property> 25 --> 26 </bean>
内建数据库的默认参数
HSQL
ConnectionUrl:"jdbc:hsqldb:mem:testdb"
Driver name:"org.hsqldb.jdbcDriver"
username:"sa"
password:""
H2
ConnectionUrl:"jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1"
Driver name:"org.h2.Driver"
username:"sa"
password:""
Derby
ConnectionUrl:"jdbc:derby:memory:testdb;create=true"
Driver name:"org.apache.derby.jdbc.EmbeddedDriver"
username:"sa"
password:""