SQLite 只需要使用单个db文件即可,不用建立数据库服务。非常简单易用,适用于小型单体项目。
二、使用菜鸟教程-SQLite 教程
https://www.runoob.com/sqlite/sqlite-tutorial.html
使用Navicat可以直接新建SQLite数据库。
三、集成 SpringBoot 1、项目案例 (1)application.ymlspring:
datasource:
driver-class-name: org.sqlite.JDBC
# 路径:db/mydb.bd
#url: jdbc:sqlite:db/mydb.db
# 路径:src/main/resources/db/mydb.db
#url: jdbc:sqlite::resource:db/mydb.db
url: jdbc:sqlite:D:/Program Files/sqlite3/mydb.db
username:
password:
mybatis:
mapper-locations:
- classpath:mapper/*.xml
(2)pom.xml
(3)student.xmlorg.xerial sqlite-jdbc 3.36.0.3 org.mybatis.spring.boot mybatis-spring-boot-starter 2.2.2
src/main/resources/mapper/student.xml
(4)测试代码select "id", "name" from student where id = #{id}
src/test/java/com/scy/sqlite/SqliteApplicationTests.java
package com.scy.sqlite;
import org.apache.ibatis.session.SqlSession;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SpringBootTest
class SqliteApplicationTests {
@Resource
SqlSession sqlSession;
@Test
void contextLoads() {
Map map = new HashMap();
map.put("id", "2");
List


