知识点
相关文章
更多最近更新
更多springboot配置内存数据库测试环境
2019-03-09 23:20|来源: 网路
使用springboot+log4jdbc+hsqldb在内存当中测试环境配置
pom.xml配置为
<!-- jpa --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <scope>runtime</scope> </dependency> <!-- log4jdbc --> <dependency> <groupId>org.bgee.log4jdbc-log4j2</groupId> <artifactId>log4jdbc-log4j2-jdbc3</artifactId> <version>${log4jdbc.version}</version> <scope>test</scope> </dependency>
application.yml配置为
spring:
jpa:
hibernate:
ddl-auto: create-drop
database-platform: org.hibernate.dialect.HSQLDialect
datasource:
url: jdbc:log4jdbc:hsqldb:mem:test
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
====================
Enjoy It!
====================
Tobato 2015-08-09
====================
转自:http://tobato.iteye.com/blog/2233939
相关问答
更多-
为何安装数据库要配置环境变量?[2023-12-29]
加在环境变量里的命令可以直接使用 如果不加在环境变量里,使用数据库命令的时候还要在命令前面加上数据库命令的路径信息 -
汇编语言中定义的变量是存放在哪的?内存还是寄存器?[2022-03-09]
内存 -
springboot application.yml 怎么配置2个数据库连接[2023-06-23]
Spring Boot 是 Spring 产品中一个新的子项目,致力于简便快捷地搭建基于 Spring 的独立可运行的应用。大多数的 Spring Boot 应用只需要非常少的 Spring 配置。 你能够使用 Spring Boot 创建 Java 应用并通过 java -jar 来运行或者创建传统的通... -
php数据库应该怎样配置[2023-02-21]
一般的php空间,带MYsql的话,都会给你个帐号,数据库的用户名及密码。还有一个php的数据库管理后台,你登进去就可以可视化的操作你的数据库。最后你仔细阅读你的空间提供的相关文档。 -
一种可能的方法是DbUnit采用的方法 ,该方法提供了将表格内容导出到XML文件和从XML文件导入表格内容的类。 您可以使用它来(重新)加载预定的一组测试数据。 One possible approach is the one taken by DbUnit, which offers classes to export and import table content to and from XML files. You can use it to (re-)load your tables with a ...
-
尝试从您的环境变量中删除DATABASE_URL 。 Try removing DATABASE_URL from your environment variables.
-
你能连接到Springboot中的两个postgres数据库吗?(Can you connect to two postgres databases in Springboot?)[2022-12-30]
您需要提供两个不同的DataSources (两个不同的bean)。 看看http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-two-datasources You need to provide two different DataSources (two different beans). Take a look at http://docs.spring.io/spring-boot/docs/curre ... -
1 - 在您的引导程序中,在加载Model模块后,写入: Kohana::$config->attach(new Config_File('config/'.$_SERVER['YOUR_ENV'])); 2 - 在文件夹配置中创建一个名为$ _SERVER ['YOUR_ENV']的子文件夹“foobar” 3 - 输入你的文件> config / foobar / database.php | 不要更改“默认”键 return array ( 'default' => array ( ...
-
如果在单元测试中使用DbUnit ,则可以指定DbUnit应在每次测试之前执行清理和插入操作,以确保在每次测试之前数据库的内容都处于有效状态。 这可以通过类似于下面的方式完成: @Before public void setUp() throws Exception { logger.info("Performing the setup of test {}", testName.getMethodName()); IDatabaseConnection connection = null; ...
-
Springboot:如何跳过数据源配置运行测试(Springboot : How to skip datasource configuration running tests)[2022-05-25]
好吧,经过另一次测试,我找到了解决我的问题....我创建了一个“应用程序测试类” @SpringBootApplication public class MyAppTests { public static void main(String[] args) { SpringApplication.run(MyAppTests.class, args); } } 我更改了@SpringApplicationConfiguration的类以使用MyAppTests @RunW ...