springboot整合整合H2内存数据库实现单元测试与数据库无关性内存数据库实现单元测试与数据库无关性
本篇文章主要介绍了springboot整合H2内存数据库实现单元测试与数据库无关性,具有一定的参考价值,感兴趣的小伙伴们可以参考
一下
一、新建一、新建spring boot工程工程
新建工程的时候,需要加入JPA,H2依赖
二、工程结构二、工程结构
pom文件依赖如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.chhliu.springboot.h2</groupId>
<artifactId>springboot-h2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springboot-h2</name>
<description>Demo project for Spring Boot H2</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
评论0