<groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>${h2.version}</version> <scope>test</scope> </dependency> ⼆、运⾏⽅式 1、在内存中运⾏ 数据库只在内存中运⾏,关闭连接后数据库将被清空,适合测试环境 连接字符串:1jdbc:h2:mem:DBName;DB_CLOSE_DELAY=-1 如...
2 <jdbc:initialize-database data-source="dataSource" 3 ignore-failures="ALL"> 4 <jdbc:script location="classpath:database/h2/create-table.sql" /> 5 <jdbc:script location="classpath:database/h2/import-data.sql" /> 6 </jdbc:initialize-database> 1. 2. 3. 4. 5. 6. 配置这个以后,...
classpath*:/application.test.properties" /> <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"> <jdbc:script location="classpath:sql/h2/schema.sql" /> <jdbc:script location="classpath:data/h2/import-data.sql" encoding="UTF-8"/> /jdbc:initialize-database 四...
-- 初始化数据表结构 --> <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"> <jdbc:script location="classpath:sql/h2/schema.sql" /> <jdbc:script location="classpath:sql/h2/data.sql" encoding="UTF-8"/> </jdbc:initialize-database> </beans> 1. 2. 3. 4. 5. ...
H2 Database做为轻量级的内嵌数据库,功能十分强大,而且运行时只需要一个jar包即可,下表是官网的描述:更详细的对比见官网页面: http://www.h2database.com/html
1<!--初始化数据表结构-->2<jdbc:initialize-databasedata-source="dataSource"3ignore-failures="ALL">4<jdbc:scriptlocation="classpath:database/h2/create-table.sql"/>5<jdbc:scriptlocation="classpath:database/h2/import-data.sql"/>6</jdbc:initialize-database> ...
1<!--初始化数据表结构-->2<jdbc:initialize-databasedata-source="dataSource"3ignore-failures="ALL">4<jdbc:scriptlocation="classpath:database/h2/create-table.sql"/>5<jdbc:scriptlocation="classpath:database/h2/import-data.sql"/>6</jdbc:initialize-database> ...
com.h2database h2 ${h2.version} test 二、运行方式 1、在内存中运行 数据库只在内存中运行,关闭连接后数据库将被清空,适合测试环境 连接字符串: jdbc:h2:mem:DBName;DB_CLOSE_DELAY=-1 如果不指定DBName,则以私有方式启动,只允许一个连接 2、嵌入式 ...
Spring Profile和maven profile一样,也可以模拟不同的开发环境。在Spirng中可以通过jdbc:initialize-database初始化数据库,配置示例如下 <beansprofile="test"><context:property-placeholderignore-resource-not-found="true"location="classpath*:/application.properties, classpath*:/application.test.properties"/><!-...
4 <jdbc:script location="classpath:database/h2/create-table.sql" /> 5 <jdbc:script location="classpath:database/h2/import-data.sql" /> 6 </jdbc:initialize-database> 配置这个以后,每次应用启动前,会先执行create-table.sql,然后再执行import-data.sql,十分方便测试前,先初始化db环境 ...