目录
(1)SQLite 是一个非常轻量级的数据库。 因此在电脑,手机,相机,家用电子设备等设备
的嵌入式软件是非常好的选择。
(2)SQLite 的数据存储非常简单高效。 当您需要存储文件存档时,SQLite可以生成较小数据量的存档,并且包含常规ZIP存档的大量元数据。
(3)SQLite 可以用作临时数据集,以对应用程序中的一些数据进行一些处理。
(4)SQLite 数据库中,数据查询非常简单。 您可以将数据加载到SQLite内存数据库中,并随时提取数据。可以按照您想要的方式提取数据。
(5)SQLite 提供了一种简单有效的方式来处理数据,而不是以内存变量来做数据处理。 例如:如果您正在开发一个程序,并且有一些记录要对其进行一些计算。 然后,您可以创建一个SQLite数据库并在其中插入记录,查询,可以选择记录并直接进行所需的计算。
(6)SQLite 非常容易学习和使用。它不需要任何安装和配置。只需复制计算机中的SQLite库,就可以创建数据库了。
一、表数据
二、pom.xml
org.springframework.boot
spring-boot-starter-web
org.xerial
sqlite-jdbc
3.36.0.3
com.baomidou
mybatis-plus-boot-starter
3.4.3.4
org.projectlombok
lombok
1.18.20
provided
三、ymal配置
spring:
# 配置Sqlite3数据库连接
datasource:
name: sqlite3
driver-class-name: org.sqlite.JDBC #数据库链接驱动
url: jdbc:sqlite::resource:static/sqlite/test.db #数据库链接地址
username:
password:
# 指定静态资源文件路径
mvc:
static-path-pattern: /static/**
Mybatis-Plus 数据库框架
mybatis-plus:
# 搜索指定包别名---配置实体类
mapper-locations: classpath*:mapper/**/*Mapper.xml
# 配置mapper的扫描,找到所有的mapper.xml映射文件---配置映射文件,与包名下mapper目录中带有@Mapper注解接口进行数据交互
type-aliases-package: com.web.zy.entity
# 加载全局参数配置文件
config-location: classpath:mybatis-config.xml
# 服务配置
server:
port: 8085
四、Person实体
@Data
public class Person extends Model {
private Integer pId;
private String pName;
private String pAge;
}
五、mapper
@Mapper
public interface PersonMapper extends BaseMapper {
}
六、service及实现类
public interface PersonService extends IService {
}
@Service
public class PersonServiceImpl extends ServiceImpl implements PersonService {
}
七、Controller
@RestController
public class PersonController {
/**
* 从IOC容器中获取业务层对象
*/
@Autowired
PersonService personService;
/**
* 查询表中全部数据,返回json格式
*
* @return 实体集合
*/
@RequestMapping(value = "/people")
public List index() {
return personService.list();
}
}
八、Mybatis映射文件
p_id,p_name,p_age
九、启动测试
十、总结
仅自己学习记录,如有错误,敬请谅解~,谢谢~~~
Original: https://blog.csdn.net/qq_39038178/article/details/126142927
Author: 电竞丶小松哥
Title: (Spring笔记)SpringBoot+Mybatis+Sqlite3查询表数据
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/815868/
转载文章受原作者版权保护。转载请注明原作者出处!